fengming 0.3.10 → 0.3.11

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 (761) hide show
  1. package/dist/build-info.json +2 -2
  2. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  3. package/dist/cli-startup-metadata.json +8 -8
  4. package/dist/control-ui/assets/{activity-D-mnRThU.js → activity-wgT0-JR0.js} +2 -2
  5. package/dist/control-ui/assets/{agents-U_KSP5I_.js → agents-DG5PobrT.js} +2 -2
  6. package/dist/control-ui/assets/{channels-ohK9_G1O.js → channels-CX28oM42.js} +2 -2
  7. package/dist/control-ui/assets/{cron-6ZCzfU29.js → cron-B8ixwBqU.js} +2 -2
  8. package/dist/control-ui/assets/{debug-CSsDLg_s.js → debug-CnkYZUXy.js} +2 -2
  9. package/dist/control-ui/assets/{index-jUDczxhd.js → index-DQRZJKbO.js} +4 -4
  10. package/dist/control-ui/assets/{instances-782ZoDT4.js → instances-BE3mV1JC.js} +2 -2
  11. package/dist/control-ui/assets/{nodes-BMX16BKM.js → nodes-Cou4PWRX.js} +2 -2
  12. package/dist/control-ui/assets/{sessions-jLGSApYa.js → sessions-DpAaBT21.js} +2 -2
  13. package/dist/control-ui/assets/{skills-DweBwUhs.js → skills-DjA_j_20.js} +2 -2
  14. package/dist/control-ui/assets/{workboard-BsU-FXIo.js → workboard-BFnvbS0k.js} +2 -2
  15. package/dist/control-ui/index.html +1 -1
  16. package/dist/control-ui/sw.js +1 -1
  17. package/dist/gateway/protocol/index.d.ts +1 -1
  18. package/dist/{index-AZzJCgph.d.ts → index-DuDY3bCZ.d.ts} +2 -2
  19. package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
  20. package/dist/plugin-sdk/agent-config-primitives.d.ts +1 -1
  21. package/dist/plugin-sdk/{bundled-channel-config-schema-Dfn3b8sF.d.ts → bundled-channel-config-schema-BPFNnbwu.d.ts} +23 -23
  22. package/dist/plugin-sdk/bundled-channel-config-schema.d.ts +3 -3
  23. package/dist/plugin-sdk/channel-config-primitives.d.ts +2 -2
  24. package/dist/plugin-sdk/channel-config-schema-legacy.d.ts +3 -3
  25. package/dist/plugin-sdk/channel-config-schema.d.ts +2 -2
  26. package/dist/plugin-sdk/channel-core.d.ts +1 -1
  27. package/dist/plugin-sdk/channel-plugin-common.d.ts +1 -1
  28. package/dist/plugin-sdk/compat.d.ts +2 -2
  29. package/dist/plugin-sdk/{config-schema-DUddICQM.d.ts → config-schema-D7cABQ6o.d.ts} +1 -1
  30. package/dist/plugin-sdk/config-schema.d.ts +2 -2
  31. package/dist/plugin-sdk/core.d.ts +1 -1
  32. package/dist/plugin-sdk/discord.d.ts +2 -2
  33. package/dist/plugin-sdk/tts-runtime.d.ts +1 -1
  34. package/dist/plugin-sdk/{zod-schema.core-B4_b2R5K.d.ts → zod-schema.core-CwBNqcXp.d.ts} +1 -1
  35. package/package.json +4 -409
  36. package/CHANGELOG.md +0 -42
  37. package/THIRD_PARTY_NOTICES.md +0 -37
  38. package/docs/.i18n/README.md +0 -81
  39. package/docs/.i18n/ar-navigation.json +0 -18
  40. package/docs/.i18n/de-navigation.json +0 -18
  41. package/docs/.i18n/es-navigation.json +0 -18
  42. package/docs/.i18n/fr-navigation.json +0 -18
  43. package/docs/.i18n/glossary.ar.json +0 -78
  44. package/docs/.i18n/glossary.de.json +0 -78
  45. package/docs/.i18n/glossary.es.json +0 -78
  46. package/docs/.i18n/glossary.fa.json +0 -78
  47. package/docs/.i18n/glossary.fr.json +0 -78
  48. package/docs/.i18n/glossary.id.json +0 -78
  49. package/docs/.i18n/glossary.it.json +0 -78
  50. package/docs/.i18n/glossary.ja-JP.json +0 -98
  51. package/docs/.i18n/glossary.ko.json +0 -78
  52. package/docs/.i18n/glossary.nl.json +0 -78
  53. package/docs/.i18n/glossary.pl.json +0 -78
  54. package/docs/.i18n/glossary.pt-BR.json +0 -78
  55. package/docs/.i18n/glossary.th.json +0 -78
  56. package/docs/.i18n/glossary.tr.json +0 -78
  57. package/docs/.i18n/glossary.uk.json +0 -78
  58. package/docs/.i18n/glossary.vi.json +0 -78
  59. package/docs/.i18n/glossary.zh-CN.json +0 -1122
  60. package/docs/.i18n/glossary.zh-TW.json +0 -78
  61. package/docs/.i18n/id-navigation.json +0 -18
  62. package/docs/.i18n/it-navigation.json +0 -18
  63. package/docs/.i18n/ja-navigation.json +0 -18
  64. package/docs/.i18n/ko-navigation.json +0 -18
  65. package/docs/.i18n/pl-navigation.json +0 -18
  66. package/docs/.i18n/pt-BR-navigation.json +0 -18
  67. package/docs/.i18n/tr-navigation.json +0 -18
  68. package/docs/.i18n/translation-workflow.md +0 -111
  69. package/docs/.i18n/zh-Hans-navigation.json +0 -552
  70. package/docs/AGENTS.md +0 -36
  71. package/docs/CLAUDE.md +0 -1
  72. package/docs/agent-runtime-architecture.md +0 -48
  73. package/docs/announcements/bluebubbles-imessage.md +0 -79
  74. package/docs/auth-credential-semantics.md +0 -124
  75. package/docs/automation/auth-monitoring.md +0 -11
  76. package/docs/automation/clawflow.md +0 -12
  77. package/docs/automation/cron-jobs.md +0 -534
  78. package/docs/automation/cron-vs-heartbeat.md +0 -11
  79. package/docs/automation/gmail-pubsub.md +0 -11
  80. package/docs/automation/hooks.md +0 -387
  81. package/docs/automation/index.md +0 -135
  82. package/docs/automation/poll.md +0 -12
  83. package/docs/automation/standing-orders.md +0 -250
  84. package/docs/automation/taskflow.md +0 -155
  85. package/docs/automation/tasks.md +0 -374
  86. package/docs/automation/troubleshooting.md +0 -12
  87. package/docs/automation/webhook.md +0 -12
  88. package/docs/brave-search.md +0 -11
  89. package/docs/channels/access-groups.md +0 -201
  90. package/docs/channels/ambient-room-events.md +0 -214
  91. package/docs/channels/bot-loop-protection.md +0 -131
  92. package/docs/channels/broadcast-groups.md +0 -472
  93. package/docs/channels/channel-routing.md +0 -162
  94. package/docs/channels/clickclack.md +0 -138
  95. package/docs/channels/discord.md +0 -1758
  96. package/docs/channels/feishu.md +0 -650
  97. package/docs/channels/googlechat.md +0 -284
  98. package/docs/channels/group-messages.md +0 -95
  99. package/docs/channels/groups.md +0 -524
  100. package/docs/channels/imessage-from-bluebubbles.md +0 -259
  101. package/docs/channels/imessage.md +0 -839
  102. package/docs/channels/index.md +0 -64
  103. package/docs/channels/irc.md +0 -253
  104. package/docs/channels/line.md +0 -243
  105. package/docs/channels/location.md +0 -71
  106. package/docs/channels/matrix-migration.md +0 -370
  107. package/docs/channels/matrix-presentation.md +0 -77
  108. package/docs/channels/matrix-push-rules.md +0 -150
  109. package/docs/channels/matrix.md +0 -921
  110. package/docs/channels/mattermost.md +0 -542
  111. package/docs/channels/msteams.md +0 -1096
  112. package/docs/channels/nextcloud-talk.md +0 -176
  113. package/docs/channels/nostr.md +0 -253
  114. package/docs/channels/pairing.md +0 -214
  115. package/docs/channels/qqbot.md +0 -314
  116. package/docs/channels/signal.md +0 -417
  117. package/docs/channels/slack.md +0 -1623
  118. package/docs/channels/synology-chat.md +0 -187
  119. package/docs/channels/telegram.md +0 -1124
  120. package/docs/channels/tlon.md +0 -296
  121. package/docs/channels/troubleshooting.md +0 -162
  122. package/docs/channels/twitch.md +0 -431
  123. package/docs/channels/wechat.md +0 -171
  124. package/docs/channels/whatsapp.md +0 -796
  125. package/docs/channels/yuanbao.md +0 -416
  126. package/docs/channels/zalo.md +0 -253
  127. package/docs/channels/zalouser.md +0 -217
  128. package/docs/ci.md +0 -657
  129. package/docs/clawhub/publishing.md +0 -96
  130. package/docs/cli/acp.md +0 -370
  131. package/docs/cli/agent.md +0 -109
  132. package/docs/cli/agents.md +0 -253
  133. package/docs/cli/approvals.md +0 -190
  134. package/docs/cli/backup.md +0 -98
  135. package/docs/cli/browser.md +0 -307
  136. package/docs/cli/channels.md +0 -154
  137. package/docs/cli/clawbot.md +0 -25
  138. package/docs/cli/commitments.md +0 -90
  139. package/docs/cli/completion.md +0 -39
  140. package/docs/cli/config.md +0 -504
  141. package/docs/cli/configure.md +0 -77
  142. package/docs/cli/crestodian.md +0 -337
  143. package/docs/cli/cron.md +0 -304
  144. package/docs/cli/daemon.md +0 -67
  145. package/docs/cli/dashboard.md +0 -33
  146. package/docs/cli/devices.md +0 -240
  147. package/docs/cli/directory.md +0 -68
  148. package/docs/cli/dns.md +0 -53
  149. package/docs/cli/docs.md +0 -63
  150. package/docs/cli/doctor.md +0 -241
  151. package/docs/cli/flows.md +0 -52
  152. package/docs/cli/gateway.md +0 -572
  153. package/docs/cli/health.md +0 -43
  154. package/docs/cli/hooks.md +0 -345
  155. package/docs/cli/index.md +0 -400
  156. package/docs/cli/infer.md +0 -364
  157. package/docs/cli/logs.md +0 -68
  158. package/docs/cli/mcp.md +0 -529
  159. package/docs/cli/memory.md +0 -183
  160. package/docs/cli/message.md +0 -317
  161. package/docs/cli/migrate.md +0 -334
  162. package/docs/cli/models.md +0 -239
  163. package/docs/cli/node.md +0 -177
  164. package/docs/cli/nodes.md +0 -76
  165. package/docs/cli/onboard.md +0 -250
  166. package/docs/cli/pairing.md +0 -77
  167. package/docs/cli/path.md +0 -511
  168. package/docs/cli/plugins.md +0 -459
  169. package/docs/cli/policy.md +0 -886
  170. package/docs/cli/proxy.md +0 -89
  171. package/docs/cli/qr.md +0 -56
  172. package/docs/cli/reset.md +0 -39
  173. package/docs/cli/sandbox.md +0 -208
  174. package/docs/cli/secrets.md +0 -202
  175. package/docs/cli/security.md +0 -136
  176. package/docs/cli/sessions.md +0 -164
  177. package/docs/cli/setup.md +0 -59
  178. package/docs/cli/skills.md +0 -122
  179. package/docs/cli/status.md +0 -45
  180. package/docs/cli/system.md +0 -89
  181. package/docs/cli/tasks.md +0 -111
  182. package/docs/cli/transcripts.md +0 -151
  183. package/docs/cli/tui.md +0 -91
  184. package/docs/cli/uninstall.md +0 -44
  185. package/docs/cli/update.md +0 -243
  186. package/docs/cli/voicecall.md +0 -204
  187. package/docs/cli/webhooks.md +0 -117
  188. package/docs/cli/wiki.md +0 -256
  189. package/docs/concepts/active-memory.md +0 -856
  190. package/docs/concepts/agent-loop.md +0 -185
  191. package/docs/concepts/agent-runtimes.md +0 -276
  192. package/docs/concepts/agent-workspace.md +0 -230
  193. package/docs/concepts/agent.md +0 -140
  194. package/docs/concepts/architecture.md +0 -154
  195. package/docs/concepts/channel-docking.md +0 -145
  196. package/docs/concepts/commitments.md +0 -150
  197. package/docs/concepts/compaction.md +0 -203
  198. package/docs/concepts/context-engine.md +0 -347
  199. package/docs/concepts/context.md +0 -199
  200. package/docs/concepts/delegate-architecture.md +0 -319
  201. package/docs/concepts/dreaming.md +0 -264
  202. package/docs/concepts/experimental-features.md +0 -109
  203. package/docs/concepts/features.md +0 -91
  204. package/docs/concepts/fengming-sdk.md +0 -323
  205. package/docs/concepts/mantis-slack-desktop-runbook.md +0 -231
  206. package/docs/concepts/mantis.md +0 -744
  207. package/docs/concepts/markdown-formatting.md +0 -139
  208. package/docs/concepts/memory-builtin.md +0 -148
  209. package/docs/concepts/memory-honcho.md +0 -144
  210. package/docs/concepts/memory-qmd.md +0 -271
  211. package/docs/concepts/memory-search.md +0 -167
  212. package/docs/concepts/memory.md +0 -299
  213. package/docs/concepts/message-lifecycle-refactor.md +0 -1126
  214. package/docs/concepts/messages.md +0 -214
  215. package/docs/concepts/model-failover.md +0 -384
  216. package/docs/concepts/model-providers.md +0 -719
  217. package/docs/concepts/models.md +0 -371
  218. package/docs/concepts/multi-agent.md +0 -625
  219. package/docs/concepts/oauth.md +0 -198
  220. package/docs/concepts/parallel-specialist-lanes.md +0 -127
  221. package/docs/concepts/personal-agent-benchmark-pack.md +0 -74
  222. package/docs/concepts/presence.md +0 -117
  223. package/docs/concepts/progress-drafts.md +0 -406
  224. package/docs/concepts/qa-e2e-automation.md +0 -947
  225. package/docs/concepts/qa-matrix.md +0 -139
  226. package/docs/concepts/queue-steering.md +0 -90
  227. package/docs/concepts/queue.md +0 -136
  228. package/docs/concepts/retry.md +0 -86
  229. package/docs/concepts/session-pruning.md +0 -104
  230. package/docs/concepts/session-tool.md +0 -188
  231. package/docs/concepts/session.md +0 -164
  232. package/docs/concepts/soul.md +0 -116
  233. package/docs/concepts/streaming.md +0 -257
  234. package/docs/concepts/system-prompt.md +0 -328
  235. package/docs/concepts/timezone.md +0 -47
  236. package/docs/concepts/typebox.md +0 -309
  237. package/docs/concepts/typing-indicators.md +0 -88
  238. package/docs/concepts/usage-tracking.md +0 -66
  239. package/docs/date-time.md +0 -126
  240. package/docs/debug/node-issue.md +0 -90
  241. package/docs/diagnostics/flags.md +0 -182
  242. package/docs/docs.json +0 -1862
  243. package/docs/fengming-agent-runtime.md +0 -82
  244. package/docs/gateway/authentication.md +0 -256
  245. package/docs/gateway/background-process.md +0 -147
  246. package/docs/gateway/bonjour.md +0 -303
  247. package/docs/gateway/bridge-protocol.md +0 -97
  248. package/docs/gateway/cli-backends.md +0 -439
  249. package/docs/gateway/config-agents.md +0 -1525
  250. package/docs/gateway/config-channels.md +0 -945
  251. package/docs/gateway/config-tools.md +0 -774
  252. package/docs/gateway/configuration-examples.md +0 -704
  253. package/docs/gateway/configuration-reference.md +0 -1391
  254. package/docs/gateway/configuration.md +0 -739
  255. package/docs/gateway/diagnostics.md +0 -213
  256. package/docs/gateway/discovery.md +0 -154
  257. package/docs/gateway/doctor.md +0 -575
  258. package/docs/gateway/gateway-lock.md +0 -37
  259. package/docs/gateway/health.md +0 -73
  260. package/docs/gateway/heartbeat.md +0 -498
  261. package/docs/gateway/index.md +0 -383
  262. package/docs/gateway/local-model-services.md +0 -205
  263. package/docs/gateway/local-models.md +0 -355
  264. package/docs/gateway/logging.md +0 -149
  265. package/docs/gateway/multiple-gateways.md +0 -178
  266. package/docs/gateway/network-model.md +0 -15
  267. package/docs/gateway/openai-http-api.md +0 -378
  268. package/docs/gateway/openresponses-http-api.md +0 -347
  269. package/docs/gateway/openshell.md +0 -316
  270. package/docs/gateway/opentelemetry.md +0 -433
  271. package/docs/gateway/operator-scopes.md +0 -119
  272. package/docs/gateway/pairing.md +0 -207
  273. package/docs/gateway/prometheus.md +0 -249
  274. package/docs/gateway/protocol.md +0 -826
  275. package/docs/gateway/remote-gateway-readme.md +0 -169
  276. package/docs/gateway/remote.md +0 -280
  277. package/docs/gateway/sandbox-vs-tool-policy-vs-elevated.md +0 -148
  278. package/docs/gateway/sandboxing.md +0 -546
  279. package/docs/gateway/secrets-plan-contract.md +0 -159
  280. package/docs/gateway/secrets.md +0 -805
  281. package/docs/gateway/security/audit-checks.md +0 -127
  282. package/docs/gateway/security/exposure-runbook.md +0 -212
  283. package/docs/gateway/security/index.md +0 -1343
  284. package/docs/gateway/security/secure-file-operations.md +0 -76
  285. package/docs/gateway/security/shrinkwrap.md +0 -111
  286. package/docs/gateway/tailscale.md +0 -156
  287. package/docs/gateway/tools-invoke-http-api.md +0 -169
  288. package/docs/gateway/troubleshooting.md +0 -877
  289. package/docs/gateway/trusted-proxy-auth.md +0 -483
  290. package/docs/help/debugging.md +0 -341
  291. package/docs/help/environment.md +0 -233
  292. package/docs/help/faq-first-run.md +0 -870
  293. package/docs/help/faq-models.md +0 -556
  294. package/docs/help/faq.md +0 -2041
  295. package/docs/help/index.md +0 -39
  296. package/docs/help/scripts.md +0 -56
  297. package/docs/help/testing-live.md +0 -587
  298. package/docs/help/testing-updates-plugins.md +0 -299
  299. package/docs/help/testing.md +0 -977
  300. package/docs/help/troubleshooting.md +0 -449
  301. package/docs/index.md +0 -196
  302. package/docs/install/ansible.md +0 -233
  303. package/docs/install/azure.md +0 -315
  304. package/docs/install/bun.md +0 -59
  305. package/docs/install/clawdock.md +0 -112
  306. package/docs/install/development-channels.md +0 -148
  307. package/docs/install/digitalocean.md +0 -174
  308. package/docs/install/docker-vm-runtime.md +0 -154
  309. package/docs/install/docker.md +0 -564
  310. package/docs/install/exe-dev.md +0 -201
  311. package/docs/install/fly.md +0 -524
  312. package/docs/install/gcp.md +0 -418
  313. package/docs/install/hetzner.md +0 -285
  314. package/docs/install/hostinger.md +0 -98
  315. package/docs/install/index.md +0 -232
  316. package/docs/install/installer.md +0 -447
  317. package/docs/install/kubernetes.md +0 -196
  318. package/docs/install/macos-vm.md +0 -281
  319. package/docs/install/migrating-claude.md +0 -165
  320. package/docs/install/migrating-hermes.md +0 -178
  321. package/docs/install/migrating.md +0 -137
  322. package/docs/install/nix.md +0 -112
  323. package/docs/install/node.md +0 -142
  324. package/docs/install/northflank.mdx +0 -44
  325. package/docs/install/oracle.md +0 -218
  326. package/docs/install/podman.md +0 -216
  327. package/docs/install/railway.mdx +0 -92
  328. package/docs/install/raspberry-pi.md +0 -234
  329. package/docs/install/render.mdx +0 -167
  330. package/docs/install/uninstall.md +0 -131
  331. package/docs/install/updating.md +0 -284
  332. package/docs/install/upstash.md +0 -96
  333. package/docs/logging.md +0 -320
  334. package/docs/nav-tabs-underline.js +0 -100
  335. package/docs/network.md +0 -72
  336. package/docs/nodes/audio.md +0 -216
  337. package/docs/nodes/camera.md +0 -166
  338. package/docs/nodes/images.md +0 -77
  339. package/docs/nodes/index.md +0 -439
  340. package/docs/nodes/location-command.md +0 -102
  341. package/docs/nodes/media-understanding.md +0 -495
  342. package/docs/nodes/talk.md +0 -160
  343. package/docs/nodes/troubleshooting.md +0 -123
  344. package/docs/nodes/voicewake.md +0 -93
  345. package/docs/perplexity.md +0 -11
  346. package/docs/plan/codex-context-engine-harness.md +0 -624
  347. package/docs/plan/ui-channels.md +0 -284
  348. package/docs/platforms/digitalocean.md +0 -12
  349. package/docs/platforms/easyrunner.md +0 -109
  350. package/docs/platforms/index.md +0 -51
  351. package/docs/platforms/linux.md +0 -141
  352. package/docs/platforms/mac/bundled-gateway.md +0 -79
  353. package/docs/platforms/mac/canvas.md +0 -128
  354. package/docs/platforms/mac/child-process.md +0 -72
  355. package/docs/platforms/mac/dev-setup.md +0 -112
  356. package/docs/platforms/mac/health.md +0 -39
  357. package/docs/platforms/mac/icon.md +0 -36
  358. package/docs/platforms/mac/logging.md +0 -62
  359. package/docs/platforms/mac/menu-bar.md +0 -93
  360. package/docs/platforms/mac/peekaboo.md +0 -96
  361. package/docs/platforms/mac/permissions.md +0 -73
  362. package/docs/platforms/mac/remote.md +0 -123
  363. package/docs/platforms/mac/signing.md +0 -52
  364. package/docs/platforms/mac/skills.md +0 -43
  365. package/docs/platforms/mac/voice-overlay.md +0 -66
  366. package/docs/platforms/mac/voicewake.md +0 -73
  367. package/docs/platforms/mac/webchat.md +0 -54
  368. package/docs/platforms/mac/xpc.md +0 -66
  369. package/docs/platforms/oracle.md +0 -12
  370. package/docs/platforms/raspberry-pi.md +0 -13
  371. package/docs/platforms/windows.md +0 -286
  372. package/docs/plugins/adding-capabilities.md +0 -146
  373. package/docs/plugins/admin-http-rpc.md +0 -216
  374. package/docs/plugins/agent-tools.md +0 -13
  375. package/docs/plugins/architecture-internals.md +0 -1196
  376. package/docs/plugins/architecture.md +0 -483
  377. package/docs/plugins/building-extensions.md +0 -13
  378. package/docs/plugins/building-plugins.md +0 -335
  379. package/docs/plugins/bundles.md +0 -310
  380. package/docs/plugins/cli-backend-plugins.md +0 -310
  381. package/docs/plugins/codex-computer-use.md +0 -297
  382. package/docs/plugins/codex-harness-reference.md +0 -470
  383. package/docs/plugins/codex-harness-runtime.md +0 -268
  384. package/docs/plugins/codex-harness.md +0 -780
  385. package/docs/plugins/codex-native-plugins.md +0 -276
  386. package/docs/plugins/community.md +0 -77
  387. package/docs/plugins/compatibility.md +0 -167
  388. package/docs/plugins/copilot.md +0 -356
  389. package/docs/plugins/dependency-resolution.md +0 -176
  390. package/docs/plugins/google-meet.md +0 -1737
  391. package/docs/plugins/hooks.md +0 -484
  392. package/docs/plugins/install-overrides.md +0 -80
  393. package/docs/plugins/manage-plugins.md +0 -210
  394. package/docs/plugins/manifest.md +0 -1457
  395. package/docs/plugins/memory-lancedb.md +0 -385
  396. package/docs/plugins/memory-wiki.md +0 -529
  397. package/docs/plugins/message-presentation.md +0 -473
  398. package/docs/plugins/oc-path.md +0 -166
  399. package/docs/plugins/plugin-inventory.md +0 -189
  400. package/docs/plugins/plugin-permission-requests.md +0 -193
  401. package/docs/plugins/reference/acpx.md +0 -23
  402. package/docs/plugins/reference/admin-http-rpc.md +0 -23
  403. package/docs/plugins/reference/alibaba.md +0 -23
  404. package/docs/plugins/reference/amazon-bedrock-mantle.md +0 -23
  405. package/docs/plugins/reference/amazon-bedrock.md +0 -23
  406. package/docs/plugins/reference/anthropic-vertex.md +0 -19
  407. package/docs/plugins/reference/anthropic.md +0 -23
  408. package/docs/plugins/reference/arcee.md +0 -23
  409. package/docs/plugins/reference/azure-speech.md +0 -23
  410. package/docs/plugins/reference/bonjour.md +0 -19
  411. package/docs/plugins/reference/brave.md +0 -23
  412. package/docs/plugins/reference/browser.md +0 -23
  413. package/docs/plugins/reference/byteplus.md +0 -19
  414. package/docs/plugins/reference/canvas.md +0 -19
  415. package/docs/plugins/reference/cerebras.md +0 -23
  416. package/docs/plugins/reference/chutes.md +0 -23
  417. package/docs/plugins/reference/clickclack.md +0 -23
  418. package/docs/plugins/reference/cloudflare-ai-gateway.md +0 -23
  419. package/docs/plugins/reference/codex-supervisor.md +0 -27
  420. package/docs/plugins/reference/codex.md +0 -23
  421. package/docs/plugins/reference/comfy.md +0 -23
  422. package/docs/plugins/reference/copilot-proxy.md +0 -19
  423. package/docs/plugins/reference/copilot.md +0 -23
  424. package/docs/plugins/reference/deepgram.md +0 -23
  425. package/docs/plugins/reference/deepinfra.md +0 -23
  426. package/docs/plugins/reference/deepseek.md +0 -23
  427. package/docs/plugins/reference/diagnostics-otel.md +0 -19
  428. package/docs/plugins/reference/diagnostics-prometheus.md +0 -19
  429. package/docs/plugins/reference/diffs-language-pack.md +0 -19
  430. package/docs/plugins/reference/diffs.md +0 -19
  431. package/docs/plugins/reference/discord.md +0 -23
  432. package/docs/plugins/reference/document-extract.md +0 -23
  433. package/docs/plugins/reference/duckduckgo.md +0 -23
  434. package/docs/plugins/reference/elevenlabs.md +0 -23
  435. package/docs/plugins/reference/exa.md +0 -23
  436. package/docs/plugins/reference/fal.md +0 -23
  437. package/docs/plugins/reference/feishu.md +0 -23
  438. package/docs/plugins/reference/file-transfer.md +0 -19
  439. package/docs/plugins/reference/firecrawl.md +0 -23
  440. package/docs/plugins/reference/fireworks.md +0 -23
  441. package/docs/plugins/reference/github-copilot.md +0 -23
  442. package/docs/plugins/reference/gmi.md +0 -23
  443. package/docs/plugins/reference/google-meet.md +0 -23
  444. package/docs/plugins/reference/google.md +0 -23
  445. package/docs/plugins/reference/googlechat.md +0 -23
  446. package/docs/plugins/reference/gradium.md +0 -23
  447. package/docs/plugins/reference/groq.md +0 -23
  448. package/docs/plugins/reference/huggingface.md +0 -23
  449. package/docs/plugins/reference/imessage.md +0 -23
  450. package/docs/plugins/reference/inworld.md +0 -23
  451. package/docs/plugins/reference/irc.md +0 -23
  452. package/docs/plugins/reference/kilocode.md +0 -23
  453. package/docs/plugins/reference/kimi.md +0 -23
  454. package/docs/plugins/reference/line.md +0 -23
  455. package/docs/plugins/reference/litellm.md +0 -23
  456. package/docs/plugins/reference/llm-task.md +0 -19
  457. package/docs/plugins/reference/lmstudio.md +0 -23
  458. package/docs/plugins/reference/lobster.md +0 -19
  459. package/docs/plugins/reference/matrix.md +0 -23
  460. package/docs/plugins/reference/mattermost.md +0 -23
  461. package/docs/plugins/reference/memory-core.md +0 -19
  462. package/docs/plugins/reference/memory-lancedb.md +0 -23
  463. package/docs/plugins/reference/memory-wiki.md +0 -23
  464. package/docs/plugins/reference/microsoft-foundry.md +0 -19
  465. package/docs/plugins/reference/microsoft.md +0 -19
  466. package/docs/plugins/reference/migrate-claude.md +0 -19
  467. package/docs/plugins/reference/migrate-hermes.md +0 -19
  468. package/docs/plugins/reference/minimax.md +0 -23
  469. package/docs/plugins/reference/mistral.md +0 -23
  470. package/docs/plugins/reference/moonshot.md +0 -23
  471. package/docs/plugins/reference/msteams.md +0 -23
  472. package/docs/plugins/reference/nextcloud-talk.md +0 -23
  473. package/docs/plugins/reference/nostr.md +0 -23
  474. package/docs/plugins/reference/novita.md +0 -23
  475. package/docs/plugins/reference/nvidia.md +0 -23
  476. package/docs/plugins/reference/oc-path.md +0 -23
  477. package/docs/plugins/reference/ollama.md +0 -23
  478. package/docs/plugins/reference/open-prose.md +0 -19
  479. package/docs/plugins/reference/openai.md +0 -23
  480. package/docs/plugins/reference/opencode-go.md +0 -23
  481. package/docs/plugins/reference/opencode.md +0 -23
  482. package/docs/plugins/reference/openrouter.md +0 -23
  483. package/docs/plugins/reference/openshell.md +0 -19
  484. package/docs/plugins/reference/perplexity.md +0 -23
  485. package/docs/plugins/reference/pixverse.md +0 -23
  486. package/docs/plugins/reference/policy.md +0 -72
  487. package/docs/plugins/reference/qa-channel.md +0 -23
  488. package/docs/plugins/reference/qa-lab.md +0 -19
  489. package/docs/plugins/reference/qa-matrix.md +0 -19
  490. package/docs/plugins/reference/qianfan.md +0 -23
  491. package/docs/plugins/reference/qqbot.md +0 -23
  492. package/docs/plugins/reference/qwen.md +0 -23
  493. package/docs/plugins/reference/runway.md +0 -23
  494. package/docs/plugins/reference/searxng.md +0 -19
  495. package/docs/plugins/reference/senseaudio.md +0 -23
  496. package/docs/plugins/reference/sglang.md +0 -23
  497. package/docs/plugins/reference/signal.md +0 -23
  498. package/docs/plugins/reference/skill-workshop.md +0 -23
  499. package/docs/plugins/reference/slack.md +0 -23
  500. package/docs/plugins/reference/stepfun.md +0 -23
  501. package/docs/plugins/reference/synology-chat.md +0 -23
  502. package/docs/plugins/reference/synthetic.md +0 -23
  503. package/docs/plugins/reference/tavily.md +0 -23
  504. package/docs/plugins/reference/telegram.md +0 -23
  505. package/docs/plugins/reference/tencent.md +0 -23
  506. package/docs/plugins/reference/tlon.md +0 -23
  507. package/docs/plugins/reference/together.md +0 -23
  508. package/docs/plugins/reference/tokenjuice.md +0 -23
  509. package/docs/plugins/reference/tts-local-cli.md +0 -19
  510. package/docs/plugins/reference/twitch.md +0 -23
  511. package/docs/plugins/reference/venice.md +0 -23
  512. package/docs/plugins/reference/vercel-ai-gateway.md +0 -23
  513. package/docs/plugins/reference/vllm.md +0 -23
  514. package/docs/plugins/reference/voice-call.md +0 -23
  515. package/docs/plugins/reference/volcengine.md +0 -23
  516. package/docs/plugins/reference/voyage.md +0 -19
  517. package/docs/plugins/reference/vydra.md +0 -23
  518. package/docs/plugins/reference/web-readability.md +0 -19
  519. package/docs/plugins/reference/webhooks.md +0 -23
  520. package/docs/plugins/reference/whatsapp.md +0 -23
  521. package/docs/plugins/reference/workboard.md +0 -23
  522. package/docs/plugins/reference/xai.md +0 -23
  523. package/docs/plugins/reference/xiaomi.md +0 -23
  524. package/docs/plugins/reference/zai.md +0 -23
  525. package/docs/plugins/reference/zalo.md +0 -23
  526. package/docs/plugins/reference/zalouser.md +0 -24
  527. package/docs/plugins/reference.md +0 -145
  528. package/docs/plugins/sdk-agent-harness.md +0 -338
  529. package/docs/plugins/sdk-channel-inbound.md +0 -70
  530. package/docs/plugins/sdk-channel-ingress.md +0 -137
  531. package/docs/plugins/sdk-channel-message.md +0 -18
  532. package/docs/plugins/sdk-channel-outbound.md +0 -113
  533. package/docs/plugins/sdk-channel-plugins.md +0 -765
  534. package/docs/plugins/sdk-channel-turn.md +0 -9
  535. package/docs/plugins/sdk-entrypoints.md +0 -344
  536. package/docs/plugins/sdk-migration.md +0 -979
  537. package/docs/plugins/sdk-overview.md +0 -511
  538. package/docs/plugins/sdk-provider-plugins.md +0 -846
  539. package/docs/plugins/sdk-runtime.md +0 -676
  540. package/docs/plugins/sdk-setup.md +0 -550
  541. package/docs/plugins/sdk-subpaths.md +0 -391
  542. package/docs/plugins/sdk-testing.md +0 -403
  543. package/docs/plugins/skill-workshop.md +0 -713
  544. package/docs/plugins/tool-plugins.md +0 -411
  545. package/docs/plugins/voice-call.md +0 -942
  546. package/docs/plugins/webhooks.md +0 -192
  547. package/docs/plugins/workboard.md +0 -252
  548. package/docs/plugins/zalouser.md +0 -86
  549. package/docs/prose.md +0 -137
  550. package/docs/providers/alibaba.md +0 -158
  551. package/docs/providers/anthropic.md +0 -381
  552. package/docs/providers/arcee.md +0 -144
  553. package/docs/providers/azure-speech.md +0 -119
  554. package/docs/providers/bedrock-mantle.md +0 -211
  555. package/docs/providers/bedrock.md +0 -414
  556. package/docs/providers/cerebras.md +0 -130
  557. package/docs/providers/chutes.md +0 -153
  558. package/docs/providers/claude-max-api-proxy.md +0 -191
  559. package/docs/providers/cloudflare-ai-gateway.md +0 -119
  560. package/docs/providers/comfy.md +0 -362
  561. package/docs/providers/deepgram.md +0 -184
  562. package/docs/providers/deepinfra.md +0 -92
  563. package/docs/providers/deepseek.md +0 -146
  564. package/docs/providers/ds4.md +0 -309
  565. package/docs/providers/elevenlabs.md +0 -130
  566. package/docs/providers/fal.md +0 -240
  567. package/docs/providers/fireworks.md +0 -144
  568. package/docs/providers/github-copilot.md +0 -257
  569. package/docs/providers/gmi.md +0 -92
  570. package/docs/providers/google.md +0 -472
  571. package/docs/providers/gradium.md +0 -123
  572. package/docs/providers/groq.md +0 -171
  573. package/docs/providers/huggingface.md +0 -235
  574. package/docs/providers/index.md +0 -105
  575. package/docs/providers/inferrs.md +0 -272
  576. package/docs/providers/inworld.md +0 -120
  577. package/docs/providers/kilocode.md +0 -135
  578. package/docs/providers/litellm.md +0 -234
  579. package/docs/providers/lmstudio.md +0 -224
  580. package/docs/providers/minimax.md +0 -505
  581. package/docs/providers/mistral.md +0 -235
  582. package/docs/providers/models.md +0 -64
  583. package/docs/providers/moonshot.md +0 -413
  584. package/docs/providers/novita.md +0 -92
  585. package/docs/providers/nvidia.md +0 -158
  586. package/docs/providers/ollama-cloud.md +0 -115
  587. package/docs/providers/ollama.md +0 -1225
  588. package/docs/providers/openai.md +0 -1093
  589. package/docs/providers/opencode-go.md +0 -123
  590. package/docs/providers/opencode.md +0 -149
  591. package/docs/providers/openrouter.md +0 -349
  592. package/docs/providers/perplexity-provider.md +0 -123
  593. package/docs/providers/pixverse.md +0 -165
  594. package/docs/providers/qianfan.md +0 -132
  595. package/docs/providers/qwen-oauth.md +0 -115
  596. package/docs/providers/qwen.md +0 -364
  597. package/docs/providers/runway.md +0 -103
  598. package/docs/providers/senseaudio.md +0 -68
  599. package/docs/providers/sglang.md +0 -161
  600. package/docs/providers/stepfun.md +0 -229
  601. package/docs/providers/synthetic.md +0 -154
  602. package/docs/providers/tencent.md +0 -130
  603. package/docs/providers/together.md +0 -140
  604. package/docs/providers/venice.md +0 -312
  605. package/docs/providers/vercel-ai-gateway.md +0 -128
  606. package/docs/providers/vllm.md +0 -407
  607. package/docs/providers/volcengine.md +0 -199
  608. package/docs/providers/vydra.md +0 -180
  609. package/docs/providers/xai.md +0 -571
  610. package/docs/providers/xiaomi.md +0 -262
  611. package/docs/providers/zai.md +0 -224
  612. package/docs/refactor/access.md +0 -9
  613. package/docs/refactor/acp.md +0 -298
  614. package/docs/refactor/canvas.md +0 -131
  615. package/docs/refactor/database-first.md +0 -2256
  616. package/docs/refactor/ingress-core.md +0 -341
  617. package/docs/reference/AGENTS.default.md +0 -131
  618. package/docs/reference/RELEASING.md +0 -799
  619. package/docs/reference/api-usage-costs.md +0 -208
  620. package/docs/reference/application-modernization-plan.md +0 -208
  621. package/docs/reference/code-mode.md +0 -773
  622. package/docs/reference/credits.md +0 -33
  623. package/docs/reference/device-models.md +0 -50
  624. package/docs/reference/fengming-sdk-api-design.md +0 -390
  625. package/docs/reference/full-release-validation.md +0 -202
  626. package/docs/reference/memory-config.md +0 -604
  627. package/docs/reference/prompt-caching.md +0 -358
  628. package/docs/reference/release-performance-sweep.md +0 -360
  629. package/docs/reference/rich-output-protocol.md +0 -101
  630. package/docs/reference/rpc.md +0 -43
  631. package/docs/reference/secret-placeholder-conventions.md +0 -33
  632. package/docs/reference/secretref-credential-surface.md +0 -159
  633. package/docs/reference/secretref-user-supplied-credentials-matrix.json +0 -663
  634. package/docs/reference/session-management-compaction.md +0 -474
  635. package/docs/reference/templates/AGENTS.dev.md +0 -90
  636. package/docs/reference/templates/AGENTS.md +0 -227
  637. package/docs/reference/templates/BOOT.md +0 -16
  638. package/docs/reference/templates/BOOTSTRAP.md +0 -66
  639. package/docs/reference/templates/CLAUDE.md +0 -1
  640. package/docs/reference/templates/HEARTBEAT.md +0 -24
  641. package/docs/reference/templates/IDENTITY.dev.md +0 -52
  642. package/docs/reference/templates/IDENTITY.md +0 -34
  643. package/docs/reference/templates/SOUL.dev.md +0 -82
  644. package/docs/reference/templates/SOUL.md +0 -49
  645. package/docs/reference/templates/TOOLS.dev.md +0 -29
  646. package/docs/reference/templates/TOOLS.md +0 -51
  647. package/docs/reference/templates/USER.dev.md +0 -23
  648. package/docs/reference/templates/USER.md +0 -28
  649. package/docs/reference/test.md +0 -247
  650. package/docs/reference/token-use.md +0 -246
  651. package/docs/reference/transcript-hygiene.md +0 -214
  652. package/docs/reference/wizard.md +0 -252
  653. package/docs/security/CONTRIBUTING-THREAT-MODEL.md +0 -101
  654. package/docs/security/THREAT-MODEL-ATLAS.md +0 -611
  655. package/docs/security/formal-verification.md +0 -170
  656. package/docs/security/incident-response.md +0 -59
  657. package/docs/security/network-proxy.md +0 -268
  658. package/docs/snippets/plugin-publish/minimal-fengming.plugin.json +0 -12
  659. package/docs/snippets/plugin-publish/minimal-package.json +0 -16
  660. package/docs/specs/claw-supervisor.md +0 -247
  661. package/docs/start/bootstrapping.md +0 -49
  662. package/docs/start/docs-directory.md +0 -69
  663. package/docs/start/fengming.md +0 -252
  664. package/docs/start/getting-started.md +0 -152
  665. package/docs/start/hubs.md +0 -201
  666. package/docs/start/lore.md +0 -223
  667. package/docs/start/onboarding-overview.md +0 -72
  668. package/docs/start/onboarding.md +0 -98
  669. package/docs/start/quickstart.md +0 -25
  670. package/docs/start/setup.md +0 -178
  671. package/docs/start/showcase.md +0 -363
  672. package/docs/start/wizard-cli-automation.md +0 -232
  673. package/docs/start/wizard-cli-reference.md +0 -331
  674. package/docs/start/wizard.md +0 -141
  675. package/docs/style.css +0 -137
  676. package/docs/superpowers/specs/2026-04-22-tweakcn-custom-theme-import-design.md +0 -316
  677. package/docs/tools/acp-agents-setup.md +0 -351
  678. package/docs/tools/acp-agents.md +0 -854
  679. package/docs/tools/agent-send.md +0 -130
  680. package/docs/tools/apply-patch.md +0 -64
  681. package/docs/tools/brave-search.md +0 -139
  682. package/docs/tools/browser-control.md +0 -391
  683. package/docs/tools/browser-linux-troubleshooting.md +0 -173
  684. package/docs/tools/browser-login.md +0 -77
  685. package/docs/tools/browser-wsl2-windows-remote-cdp-troubleshooting.md +0 -219
  686. package/docs/tools/browser.md +0 -810
  687. package/docs/tools/btw.md +0 -159
  688. package/docs/tools/capability-cookbook.md +0 -12
  689. package/docs/tools/clawhub.md +0 -5
  690. package/docs/tools/code-execution.md +0 -173
  691. package/docs/tools/creating-skills.md +0 -158
  692. package/docs/tools/diffs.md +0 -525
  693. package/docs/tools/duckduckgo-search.md +0 -109
  694. package/docs/tools/elevated.md +0 -128
  695. package/docs/tools/exa-search.md +0 -152
  696. package/docs/tools/exec-approvals-advanced.md +0 -444
  697. package/docs/tools/exec-approvals.md +0 -494
  698. package/docs/tools/exec.md +0 -285
  699. package/docs/tools/firecrawl.md +0 -155
  700. package/docs/tools/gemini-search.md +0 -114
  701. package/docs/tools/goal.md +0 -217
  702. package/docs/tools/grok-search.md +0 -129
  703. package/docs/tools/image-generation.md +0 -493
  704. package/docs/tools/index.md +0 -178
  705. package/docs/tools/kimi-search.md +0 -105
  706. package/docs/tools/llm-task.md +0 -137
  707. package/docs/tools/lobster.md +0 -365
  708. package/docs/tools/loop-detection.md +0 -154
  709. package/docs/tools/media-overview.md +0 -160
  710. package/docs/tools/minimax-search.md +0 -102
  711. package/docs/tools/multi-agent-sandbox-tools.md +0 -409
  712. package/docs/tools/music-generation.md +0 -372
  713. package/docs/tools/ollama-search.md +0 -153
  714. package/docs/tools/pdf.md +0 -213
  715. package/docs/tools/perplexity-search.md +0 -220
  716. package/docs/tools/plugin.md +0 -363
  717. package/docs/tools/reactions.md +0 -100
  718. package/docs/tools/searxng-search.md +0 -141
  719. package/docs/tools/skills-config.md +0 -195
  720. package/docs/tools/skills.md +0 -569
  721. package/docs/tools/slash-commands.md +0 -487
  722. package/docs/tools/steer.md +0 -77
  723. package/docs/tools/subagents.md +0 -651
  724. package/docs/tools/tavily.md +0 -162
  725. package/docs/tools/thinking.md +0 -142
  726. package/docs/tools/tokenjuice.md +0 -84
  727. package/docs/tools/tool-search.md +0 -269
  728. package/docs/tools/trajectory.md +0 -229
  729. package/docs/tools/tts.md +0 -1009
  730. package/docs/tools/video-generation.md +0 -555
  731. package/docs/tools/web-fetch.md +0 -210
  732. package/docs/tools/web.md +0 -461
  733. package/docs/tts.md +0 -11
  734. package/docs/vps.md +0 -139
  735. package/docs/web/control-ui.md +0 -512
  736. package/docs/web/dashboard.md +0 -107
  737. package/docs/web/index.md +0 -133
  738. package/docs/web/tui.md +0 -250
  739. package/docs/web/webchat.md +0 -102
  740. package/npm-shrinkwrap.json +0 -12861
  741. package/patches/.gitkeep +0 -0
  742. package/patches/@agentclientprotocol__claude-agent-acp@0.37.0.patch +0 -41
  743. package/pnpm-workspace.yaml +0 -120
  744. package/scripts/crabbox-wrapper.mjs +0 -2004
  745. package/scripts/lib/official-external-channel-catalog.json +0 -560
  746. package/scripts/lib/official-external-plugin-catalog.json +0 -264
  747. package/scripts/lib/official-external-provider-catalog.json +0 -158
  748. package/scripts/lib/package-dist-imports.mjs +0 -171
  749. package/scripts/npm-runner.mjs +0 -91
  750. package/scripts/postinstall-bundled-plugins.mjs +0 -978
  751. package/scripts/preinstall-package-manager-warning.mjs +0 -64
  752. package/scripts/prepare-git-hooks.mjs +0 -72
  753. package/scripts/windows-cmd-helpers.mjs +0 -22
  754. package/skills/batch/SKILL.md +0 -118
  755. package/skills/code-review/SKILL.md +0 -107
  756. package/skills/debug/SKILL.md +0 -83
  757. package/skills/loop/SKILL.md +0 -118
  758. package/skills/run/SKILL.md +0 -79
  759. package/skills/run-skill-generator/SKILL.md +0 -179
  760. package/skills/verify/SKILL.md +0 -103
  761. package/src/agents/templates/HEARTBEAT.md +0 -3
@@ -1,978 +0,0 @@
1
- #!/usr/bin/env node
2
- // Runs after install to keep packaged dist safe and compatible.
3
- // Keep packaged dist safe and compatible. Plugin package dependencies are
4
- // installed only by explicit plugin install/update flows, never postinstall.
5
- import { randomUUID } from "node:crypto";
6
- import {
7
- chmodSync,
8
- closeSync,
9
- existsSync,
10
- lstatSync,
11
- openSync,
12
- readdirSync,
13
- readFileSync,
14
- readlinkSync,
15
- realpathSync,
16
- renameSync,
17
- rmdirSync,
18
- rmSync,
19
- unlinkSync,
20
- writeFileSync,
21
- } from "node:fs";
22
- import { homedir, tmpdir } from "node:os";
23
- import { basename, dirname, isAbsolute, join, relative, resolve as pathResolve } from "node:path";
24
- import { fileURLToPath, pathToFileURL } from "node:url";
25
- import { expandPackageDistImportClosure } from "./lib/package-dist-imports.mjs";
26
-
27
- const scriptDir = dirname(fileURLToPath(import.meta.url));
28
- const DEFAULT_PACKAGE_ROOT = join(scriptDir, "..");
29
- const DISABLE_POSTINSTALL_ENV = "FENGMING_DISABLE_BUNDLED_PLUGIN_POSTINSTALL";
30
- const DISABLE_PLUGIN_REGISTRY_MIGRATION_ENV = "FENGMING_DISABLE_PLUGIN_REGISTRY_MIGRATION";
31
- const DIST_INVENTORY_PATH = "dist/postinstall-inventory.json";
32
- const LEGACY_PLUGIN_RUNTIME_DEPS_DIR = "plugin-runtime-deps";
33
- const BAILEYS_MEDIA_FILE = join("node_modules", "baileys", "lib", "Utils", "messages-media.js");
34
- const BAILEYS_MEDIA_HOTFIX_NEEDLE = [
35
- " encFileWriteStream.write(mac);",
36
- " encFileWriteStream.end();",
37
- " originalFileStream?.end?.();",
38
- " stream.destroy();",
39
- " logger?.debug('encrypted data successfully');",
40
- ].join("\n");
41
- const BAILEYS_MEDIA_HOTFIX_REPLACEMENT = [
42
- " encFileWriteStream.write(mac);",
43
- " const encFinishPromise = once(encFileWriteStream, 'finish');",
44
- " const originalFinishPromise = originalFileStream ? once(originalFileStream, 'finish') : Promise.resolve();",
45
- " encFileWriteStream.end();",
46
- " originalFileStream?.end?.();",
47
- " stream.destroy();",
48
- " await Promise.all([encFinishPromise, originalFinishPromise]);",
49
- " logger?.debug('encrypted data successfully');",
50
- ].join("\n");
51
- const BAILEYS_MEDIA_HOTFIX_SEQUENTIAL_REPLACEMENT = [
52
- " encFileWriteStream.write(mac);",
53
- " const encFinishPromise = once(encFileWriteStream, 'finish');",
54
- " const originalFinishPromise = originalFileStream ? once(originalFileStream, 'finish') : Promise.resolve();",
55
- " encFileWriteStream.end();",
56
- " originalFileStream?.end?.();",
57
- " stream.destroy();",
58
- " await encFinishPromise;",
59
- " await originalFinishPromise;",
60
- " logger?.debug('encrypted data successfully');",
61
- ].join("\n");
62
- const BAILEYS_MEDIA_HOTFIX_FINISH_PROMISES_RE =
63
- /const\s+encFinishPromise\s*=\s*once\(encFileWriteStream,\s*'finish'\);\s*\n[\s\S]*const\s+originalFinishPromise\s*=\s*originalFileStream\s*\?\s*once\(originalFileStream,\s*'finish'\)\s*:\s*Promise\.resolve\(\);/u;
64
- const BAILEYS_MEDIA_HOTFIX_PROMISE_ALL_RE =
65
- /await\s+Promise\.all\(\[\s*encFinishPromise\s*,\s*originalFinishPromise\s*\]\);/u;
66
- const BAILEYS_MEDIA_HOTFIX_SEQUENTIAL_AWAITS_RE =
67
- /await\s+encFinishPromise;\s*(?:\/\/[^\n]*\n|\s)*await\s+originalFinishPromise;/u;
68
- const BAILEYS_MEDIA_DISPATCHER_NEEDLE = [
69
- " const response = await fetch(url, {",
70
- " dispatcher: fetchAgent,",
71
- " method: 'POST',",
72
- ].join("\n");
73
- const BAILEYS_MEDIA_DISPATCHER_REPLACEMENT = [
74
- " const response = await fetch(url, {",
75
- " method: 'POST',",
76
- ].join("\n");
77
- const BAILEYS_MEDIA_DISPATCHER_HEADER_NEEDLE = [
78
- " 'Content-Type': 'application/octet-stream',",
79
- " Origin: DEFAULT_ORIGIN",
80
- " },",
81
- ].join("\n");
82
- const BAILEYS_MEDIA_DISPATCHER_HEADER_REPLACEMENT = [
83
- " 'Content-Type': 'application/octet-stream',",
84
- " Origin: DEFAULT_ORIGIN",
85
- " },",
86
- " // Baileys passes a generic agent here in some runtimes. Undici's",
87
- " // `dispatcher` only works with Dispatcher-compatible implementations,",
88
- " // so only wire it through when the object actually implements",
89
- " // `dispatch`.",
90
- " ...(typeof fetchAgent?.dispatch === 'function' ? { dispatcher: fetchAgent } : {}),",
91
- ].join("\n");
92
- const BAILEYS_MEDIA_UPLOAD_WITH_FETCH_DISPATCHER_NEEDLE = [
93
- " const response = await fetch(url, {",
94
- " dispatcher: agent,",
95
- " method: 'POST',",
96
- ].join("\n");
97
- const BAILEYS_MEDIA_UPLOAD_WITH_FETCH_DISPATCHER_REPLACEMENT = [
98
- " const response = await fetch(url, {",
99
- " // Baileys may pass a generic agent in some runtimes. Undici's dispatcher",
100
- " // option only accepts Dispatcher-compatible implementations, so only wire",
101
- " // it through when the object actually implements dispatch.",
102
- " ...(typeof agent?.dispatch === 'function' ? { dispatcher: agent } : {}),",
103
- " method: 'POST',",
104
- ].join("\n");
105
- const BAILEYS_MEDIA_ONCE_IMPORT_RE = /import\s+\{\s*once\s*\}\s+from\s+['"]events['"]/u;
106
- const BAILEYS_MEDIA_ASYNC_CONTEXT_RE =
107
- /async\s+function\s+encryptedStream|encryptedStream\s*=\s*async/u;
108
- const NODE_COMPILE_CACHE_VERSION_DIR_RE = /^v\d+\.\d+\.\d+-/u;
109
-
110
- function hasEnvFlag(env, key) {
111
- const value = env?.[key]?.trim().toLowerCase();
112
- return Boolean(value && value !== "0" && value !== "false" && value !== "no");
113
- }
114
-
115
- function normalizeRelativePath(filePath) {
116
- return filePath.replace(/\\/g, "/");
117
- }
118
-
119
- function resolvePostinstallOsHomeDir(env, getHomedir = homedir) {
120
- return env?.HOME?.trim() || env?.USERPROFILE?.trim() || getHomedir();
121
- }
122
-
123
- function resolvePostinstallTildePath(input, homeDir) {
124
- if (input === "~") {
125
- return homeDir;
126
- }
127
- if (input.startsWith("~/") || input.startsWith("~\\")) {
128
- return join(homeDir, input.slice(2));
129
- }
130
- return input;
131
- }
132
-
133
- function resolvePostinstallFengMingHomeDir(env, getHomedir = homedir) {
134
- const osHome = resolvePostinstallOsHomeDir(env, getHomedir);
135
- const override = env?.FENGMING_HOME?.trim();
136
- return override ? pathResolve(resolvePostinstallTildePath(override, osHome)) : osHome;
137
- }
138
-
139
- function resolvePostinstallUserPath(input, fengMingHome) {
140
- return pathResolve(resolvePostinstallTildePath(input, fengMingHome));
141
- }
142
-
143
- function readInstalledDistInventory(params = {}) {
144
- const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;
145
- const pathExists = params.existsSync ?? existsSync;
146
- const readFile = params.readFileSync ?? readFileSync;
147
- const inventoryPath = join(packageRoot, DIST_INVENTORY_PATH);
148
- if (!pathExists(inventoryPath)) {
149
- throw new Error(`missing dist inventory: ${DIST_INVENTORY_PATH}`);
150
- }
151
- let parsed;
152
- try {
153
- parsed = JSON.parse(readFile(inventoryPath, "utf8"));
154
- } catch {
155
- throw new Error(`invalid dist inventory: ${DIST_INVENTORY_PATH}`);
156
- }
157
- if (!Array.isArray(parsed) || parsed.some((entry) => typeof entry !== "string")) {
158
- throw new Error(`invalid dist inventory: ${DIST_INVENTORY_PATH}`);
159
- }
160
- return new Set(parsed.map(normalizeRelativePath));
161
- }
162
-
163
- function isRecoverableInstalledDistInventoryError(error) {
164
- return error instanceof Error && /^(missing|invalid) dist inventory: /u.test(error.message);
165
- }
166
-
167
- function resolveInstalledDistRoot(params = {}) {
168
- const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;
169
- const pathExists = params.existsSync ?? existsSync;
170
- const pathLstat = params.lstatSync ?? lstatSync;
171
- const resolveRealPath = params.realpathSync ?? realpathSync;
172
- const distDir = join(packageRoot, "dist");
173
- if (!pathExists(distDir)) {
174
- return null;
175
- }
176
- const distStats = pathLstat(distDir);
177
- if (!distStats.isDirectory() || distStats.isSymbolicLink()) {
178
- throw new Error("unsafe dist root: dist must be a real directory");
179
- }
180
- const packageRootReal = resolveRealPath(packageRoot);
181
- const distDirReal = resolveRealPath(distDir);
182
- const relativeDistPath = relative(packageRootReal, distDirReal);
183
- if (relativeDistPath !== "dist") {
184
- throw new Error("unsafe dist root: dist escaped package root");
185
- }
186
- return { distDir, distDirReal, packageRootReal };
187
- }
188
-
189
- function assertSafeInstalledDistPath(relativePath, params) {
190
- const resolveRealPath = params.realpathSync ?? realpathSync;
191
- const candidatePath = join(params.packageRoot, relativePath);
192
- const candidateRealPath = resolveRealPath(candidatePath);
193
- const relativeCandidatePath = relative(params.distDirReal, candidateRealPath);
194
- if (relativeCandidatePath.startsWith("..") || isAbsolute(relativeCandidatePath)) {
195
- throw new Error(`unsafe dist path: ${relativePath}`);
196
- }
197
- return candidatePath;
198
- }
199
-
200
- function listInstalledDistFiles(params = {}) {
201
- const readDir = params.readdirSync ?? readdirSync;
202
- const distRoot = resolveInstalledDistRoot(params);
203
- if (distRoot === null) {
204
- return [];
205
- }
206
- const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;
207
- const pending = [distRoot.distDir];
208
- const files = [];
209
- while (pending.length > 0) {
210
- const currentDir = pending.pop();
211
- if (!currentDir) {
212
- continue;
213
- }
214
- for (const entry of readDir(currentDir, { withFileTypes: true })) {
215
- const entryPath = join(currentDir, entry.name);
216
- if (entry.isSymbolicLink()) {
217
- throw new Error(
218
- `unsafe dist entry: ${normalizeRelativePath(relative(packageRoot, entryPath))}`,
219
- );
220
- }
221
- if (entry.isDirectory()) {
222
- pending.push(entryPath);
223
- continue;
224
- }
225
- if (!entry.isFile()) {
226
- continue;
227
- }
228
- const relativePath = normalizeRelativePath(relative(packageRoot, entryPath));
229
- if (relativePath === DIST_INVENTORY_PATH) {
230
- continue;
231
- }
232
- files.push(relativePath);
233
- }
234
- }
235
- return files.toSorted((left, right) => left.localeCompare(right));
236
- }
237
-
238
- function pruneEmptyDistDirectories(params = {}) {
239
- const readDir = params.readdirSync ?? readdirSync;
240
- const removeDirectory = params.rmdirSync ?? rmdirSync;
241
- const distRoot = resolveInstalledDistRoot(params);
242
- if (distRoot === null) {
243
- return;
244
- }
245
- const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;
246
- const pathLstat = params.lstatSync ?? lstatSync;
247
-
248
- function prune(currentDir) {
249
- for (const entry of readDir(currentDir, { withFileTypes: true })) {
250
- if (entry.isSymbolicLink()) {
251
- throw new Error(
252
- `unsafe dist entry: ${normalizeRelativePath(relative(packageRoot, join(currentDir, entry.name)))}`,
253
- );
254
- }
255
- if (!entry.isDirectory()) {
256
- continue;
257
- }
258
- prune(join(currentDir, entry.name));
259
- }
260
- if (currentDir === distRoot.distDir) {
261
- return;
262
- }
263
- const currentStats = pathLstat(currentDir);
264
- if (!currentStats.isDirectory() || currentStats.isSymbolicLink()) {
265
- throw new Error(
266
- `unsafe dist directory: ${normalizeRelativePath(relative(packageRoot, currentDir))}`,
267
- );
268
- }
269
- if (readDir(currentDir).length === 0) {
270
- removeDirectory(
271
- assertSafeInstalledDistPath(normalizeRelativePath(relative(packageRoot, currentDir)), {
272
- packageRoot,
273
- distDirReal: distRoot.distDirReal,
274
- realpathSync: params.realpathSync,
275
- }),
276
- );
277
- }
278
- }
279
-
280
- prune(distRoot.distDir);
281
- }
282
-
283
- function isLegacyInstalledPluginDependencyDirName(name) {
284
- return name === "node_modules" || /^\.fengming-install-stage(?:-[^/]+)?$/iu.test(name);
285
- }
286
-
287
- function pruneLegacyInstalledPluginDependencyDirs(params) {
288
- const readDir = params.readdirSync ?? readdirSync;
289
- const removePath = params.rmSync ?? rmSync;
290
- const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;
291
- const extensionsDir = join(packageRoot, "dist", "extensions");
292
- const removed = [];
293
- let pluginEntries;
294
- try {
295
- pluginEntries = readDir(extensionsDir, { withFileTypes: true });
296
- } catch {
297
- return removed;
298
- }
299
-
300
- for (const pluginEntry of pluginEntries) {
301
- if (!pluginEntry.isDirectory() || pluginEntry.isSymbolicLink()) {
302
- continue;
303
- }
304
- const pluginDir = join(extensionsDir, pluginEntry.name);
305
- let pluginChildren;
306
- try {
307
- pluginChildren = readDir(pluginDir, { withFileTypes: true });
308
- } catch {
309
- continue;
310
- }
311
- for (const childEntry of pluginChildren) {
312
- if (!isLegacyInstalledPluginDependencyDirName(childEntry.name)) {
313
- continue;
314
- }
315
- const safePluginDir = assertSafeInstalledDistPath(
316
- normalizeRelativePath(relative(packageRoot, pluginDir)),
317
- {
318
- packageRoot,
319
- distDirReal: params.distDirReal,
320
- realpathSync: params.realpathSync,
321
- },
322
- );
323
- const relativePath = normalizeRelativePath(
324
- relative(packageRoot, join(pluginDir, childEntry.name)),
325
- );
326
- removePath(join(safePluginDir, childEntry.name), { recursive: true, force: true });
327
- removed.push(relativePath);
328
- }
329
- }
330
-
331
- return removed;
332
- }
333
-
334
- function splitPostinstallPathList(value) {
335
- return value
336
- ? value
337
- .split(pathDelimiter)
338
- .map((entry) => entry.trim())
339
- .filter(Boolean)
340
- : [];
341
- }
342
-
343
- const pathDelimiter = process.platform === "win32" ? ";" : ":";
344
-
345
- export function collectLegacyPluginRuntimeDepsStateRoots(params = {}) {
346
- const env = params.env ?? process.env;
347
- const getHomedir = params.homedir ?? homedir;
348
- const fengMingHome = resolvePostinstallFengMingHomeDir(env, getHomedir);
349
- const stateRoots = [];
350
- const addStateRoot = (root) => {
351
- if (root) {
352
- stateRoots.push(join(root, LEGACY_PLUGIN_RUNTIME_DEPS_DIR));
353
- }
354
- };
355
-
356
- const stateOverride = env?.FENGMING_STATE_DIR?.trim();
357
- if (stateOverride) {
358
- addStateRoot(resolvePostinstallUserPath(stateOverride, fengMingHome));
359
- }
360
- const configPath = env?.FENGMING_CONFIG_PATH?.trim();
361
- if (configPath) {
362
- addStateRoot(dirname(resolvePostinstallUserPath(configPath, fengMingHome)));
363
- }
364
- addStateRoot(join(fengMingHome, ".fengming"));
365
- addStateRoot(join(fengMingHome, ".clawdbot"));
366
-
367
- for (const entry of splitPostinstallPathList(env?.STATE_DIRECTORY)) {
368
- addStateRoot(resolvePostinstallUserPath(entry, fengMingHome));
369
- }
370
-
371
- return [...new Set(stateRoots.map((root) => pathResolve(root)))].toSorted((left, right) =>
372
- left.localeCompare(right),
373
- );
374
- }
375
-
376
- function isPathInsideRoot(candidate, root) {
377
- const relativePath = relative(root, candidate);
378
- return relativePath === "" || (!relativePath.startsWith("..") && !isAbsolute(relativePath));
379
- }
380
-
381
- function collectLegacyPluginRuntimeDepsSymlinkPaths(roots, params = {}) {
382
- const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;
383
- const readDir = params.readdirSync ?? readdirSync;
384
- const pathLstat = params.lstatSync ?? lstatSync;
385
- const readLink = params.readlinkSync ?? readlinkSync;
386
- const pathExists = params.existsSync ?? existsSync;
387
- const containingNodeModules = dirname(packageRoot);
388
- if (basename(containingNodeModules) !== "node_modules") {
389
- return [];
390
- }
391
-
392
- const normalizedRoots = roots.map((root) => pathResolve(root));
393
- const candidates = [];
394
- function addCandidate(linkPath) {
395
- let linkStat;
396
- try {
397
- linkStat = pathLstat(linkPath);
398
- } catch {
399
- return;
400
- }
401
- if (!linkStat.isSymbolicLink()) {
402
- return;
403
- }
404
- let target;
405
- try {
406
- target = readLink(linkPath);
407
- } catch {
408
- return;
409
- }
410
- if (!target.includes(LEGACY_PLUGIN_RUNTIME_DEPS_DIR)) {
411
- return;
412
- }
413
- const resolvedTarget = pathResolve(dirname(linkPath), target);
414
- const pointsIntoPrunedRoot = normalizedRoots.some((root) =>
415
- isPathInsideRoot(resolvedTarget, root),
416
- );
417
- if (pointsIntoPrunedRoot || !pathExists(resolvedTarget)) {
418
- candidates.push(linkPath);
419
- }
420
- }
421
-
422
- let entries;
423
- try {
424
- entries = readDir(containingNodeModules, { withFileTypes: true });
425
- } catch {
426
- return [];
427
- }
428
- for (const entry of entries) {
429
- if (entry.isDirectory() && entry.name.startsWith("@")) {
430
- const scopeDir = join(containingNodeModules, entry.name);
431
- let scopeEntries;
432
- try {
433
- scopeEntries = readDir(scopeDir, { withFileTypes: true });
434
- } catch {
435
- continue;
436
- }
437
- for (const scopeEntry of scopeEntries) {
438
- addCandidate(join(scopeDir, scopeEntry.name));
439
- }
440
- continue;
441
- }
442
- if (entry.isSymbolicLink()) {
443
- addCandidate(join(containingNodeModules, entry.name));
444
- }
445
- }
446
- return [...new Set(candidates.map((entry) => pathResolve(entry)))].toSorted((left, right) =>
447
- left.localeCompare(right),
448
- );
449
- }
450
-
451
- export function pruneLegacyPluginRuntimeDepsState(params = {}) {
452
- const pathExists = params.existsSync ?? existsSync;
453
- const removePath = params.rmSync ?? rmSync;
454
- const unlinkPath = params.unlinkSync ?? unlinkSync;
455
- const log = params.log ?? console;
456
- const removed = [];
457
- const removedSymlinks = [];
458
- const roots = collectLegacyPluginRuntimeDepsStateRoots(params);
459
-
460
- for (const linkPath of collectLegacyPluginRuntimeDepsSymlinkPaths(roots, params)) {
461
- try {
462
- unlinkPath(linkPath);
463
- removedSymlinks.push(linkPath);
464
- } catch (error) {
465
- log.warn?.(
466
- `[postinstall] could not prune legacy plugin runtime deps symlink ${linkPath}: ${String(error)}`,
467
- );
468
- }
469
- }
470
-
471
- for (const root of roots) {
472
- if (!pathExists(root)) {
473
- continue;
474
- }
475
- try {
476
- removePath(root, { recursive: true, force: true, maxRetries: 2, retryDelay: 100 });
477
- removed.push(root);
478
- } catch (error) {
479
- log.warn?.(
480
- `[postinstall] could not prune legacy plugin runtime deps ${root}: ${String(error)}`,
481
- );
482
- }
483
- }
484
-
485
- if (removed.length > 0) {
486
- log.log?.(`[postinstall] pruned legacy plugin runtime deps: ${removed.join(", ")}`);
487
- }
488
- if (removedSymlinks.length > 0) {
489
- log.log?.(
490
- `[postinstall] pruned legacy plugin runtime deps symlinks: ${removedSymlinks.join(", ")}`,
491
- );
492
- }
493
-
494
- return removed;
495
- }
496
-
497
- export function pruneInstalledPackageDist(params = {}) {
498
- const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;
499
- const removeFile = params.unlinkSync ?? unlinkSync;
500
- const log = params.log ?? console;
501
- const distRoot = resolveInstalledDistRoot(params);
502
- if (distRoot === null) {
503
- return [];
504
- }
505
- const removedLegacyDependencyDirs = pruneLegacyInstalledPluginDependencyDirs({
506
- packageRoot,
507
- distDirReal: distRoot.distDirReal,
508
- realpathSync: params.realpathSync,
509
- readdirSync: params.readdirSync,
510
- rmSync: params.rmSync,
511
- });
512
- let expectedFiles = params.expectedFiles ?? null;
513
- if (expectedFiles === null) {
514
- try {
515
- expectedFiles = readInstalledDistInventory(params);
516
- } catch (error) {
517
- if (!isRecoverableInstalledDistInventoryError(error)) {
518
- throw error;
519
- }
520
- log.warn?.(`[postinstall] skipping dist prune: ${error.message}`);
521
- return [];
522
- }
523
- }
524
- const installedFiles = listInstalledDistFiles(params);
525
- const readFile = params.readFileSync ?? readFileSync;
526
- expectedFiles = new Set(
527
- expandPackageDistImportClosure({
528
- files: installedFiles,
529
- seedFiles: [...expectedFiles],
530
- readText(relativePath) {
531
- try {
532
- return readFile(join(packageRoot, relativePath), "utf8");
533
- } catch (error) {
534
- if (error?.code === "ENOENT") {
535
- return "";
536
- }
537
- throw error;
538
- }
539
- },
540
- }),
541
- );
542
- const removed = [];
543
-
544
- for (const relativePath of installedFiles) {
545
- if (expectedFiles.has(relativePath)) {
546
- continue;
547
- }
548
- removeFile(
549
- assertSafeInstalledDistPath(relativePath, {
550
- packageRoot,
551
- distDirReal: distRoot.distDirReal,
552
- realpathSync: params.realpathSync,
553
- }),
554
- );
555
- removed.push(relativePath);
556
- }
557
-
558
- pruneEmptyDistDirectories(params);
559
-
560
- if (removed.length > 0) {
561
- log.log(`[postinstall] pruned stale dist files: ${removed.join(", ")}`);
562
- }
563
- if (removedLegacyDependencyDirs.length > 0) {
564
- log.log(
565
- `[postinstall] pruned legacy plugin dependency dirs: ${removedLegacyDependencyDirs.join(", ")}`,
566
- );
567
- }
568
- return removed;
569
- }
570
-
571
- export function applyBaileysEncryptedStreamFinishHotfix(params = {}) {
572
- const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;
573
- const pathExists = params.existsSync ?? existsSync;
574
- const pathLstat = params.lstatSync ?? lstatSync;
575
- const readFile = params.readFileSync ?? readFileSync;
576
- const resolveRealPath = params.realpathSync ?? realpathSync;
577
- const chmodFile = params.chmodSync ?? chmodSync;
578
- const openFile = params.openSync ?? openSync;
579
- const closeFile = params.closeSync ?? closeSync;
580
- const renameFile = params.renameSync ?? renameSync;
581
- const removePath = params.rmSync ?? rmSync;
582
- const createTempPath =
583
- params.createTempPath ??
584
- ((unsafeTargetPath) =>
585
- join(
586
- dirname(unsafeTargetPath),
587
- `.${basename(unsafeTargetPath)}.fengming-hotfix-${randomUUID()}`,
588
- ));
589
- const writeFile =
590
- params.writeFileSync ?? ((filePath, value) => writeFileSync(filePath, value, "utf8"));
591
- const targetPath = join(packageRoot, BAILEYS_MEDIA_FILE);
592
- const nodeModulesRoot = join(packageRoot, "node_modules");
593
-
594
- function validateTargetPath() {
595
- if (!pathExists(targetPath)) {
596
- return { ok: false, reason: "missing" };
597
- }
598
-
599
- const targetStats = pathLstat(targetPath);
600
- if (!targetStats.isFile() || targetStats.isSymbolicLink()) {
601
- return { ok: false, reason: "unsafe_target", targetPath };
602
- }
603
-
604
- const nodeModulesRootReal = resolveRealPath(nodeModulesRoot);
605
- const targetPathReal = resolveRealPath(targetPath);
606
- const relativeTargetPath = relative(nodeModulesRootReal, targetPathReal);
607
- if (relativeTargetPath.startsWith("..") || isAbsolute(relativeTargetPath)) {
608
- return { ok: false, reason: "path_escape", targetPath };
609
- }
610
-
611
- return { ok: true, targetPathReal, mode: targetStats.mode & 0o777 };
612
- }
613
-
614
- try {
615
- const initialTargetValidation = validateTargetPath();
616
- if (!initialTargetValidation.ok) {
617
- return { applied: false, reason: initialTargetValidation.reason, targetPath };
618
- }
619
-
620
- const currentText = readFile(targetPath, "utf8");
621
- let patchedText = currentText;
622
- let applied = false;
623
-
624
- const encryptedStreamAlreadyPatched =
625
- patchedText.includes(BAILEYS_MEDIA_HOTFIX_REPLACEMENT) ||
626
- patchedText.includes(BAILEYS_MEDIA_HOTFIX_SEQUENTIAL_REPLACEMENT) ||
627
- (BAILEYS_MEDIA_HOTFIX_FINISH_PROMISES_RE.test(patchedText) &&
628
- (BAILEYS_MEDIA_HOTFIX_PROMISE_ALL_RE.test(patchedText) ||
629
- BAILEYS_MEDIA_HOTFIX_SEQUENTIAL_AWAITS_RE.test(patchedText)));
630
- const encryptedStreamPatchable = patchedText.includes(BAILEYS_MEDIA_HOTFIX_NEEDLE);
631
-
632
- let encryptedStreamResolved = encryptedStreamAlreadyPatched;
633
- if (!encryptedStreamResolved && encryptedStreamPatchable) {
634
- if (!BAILEYS_MEDIA_ONCE_IMPORT_RE.test(patchedText)) {
635
- return { applied: false, reason: "missing_once_import", targetPath };
636
- }
637
- if (!BAILEYS_MEDIA_ASYNC_CONTEXT_RE.test(patchedText)) {
638
- return { applied: false, reason: "not_async_context", targetPath };
639
- }
640
- patchedText = patchedText.replace(
641
- BAILEYS_MEDIA_HOTFIX_NEEDLE,
642
- BAILEYS_MEDIA_HOTFIX_REPLACEMENT,
643
- );
644
- applied = true;
645
- encryptedStreamResolved = true;
646
- }
647
-
648
- const dispatcherAlreadyPatched =
649
- patchedText.includes(
650
- "...(typeof fetchAgent?.dispatch === 'function' ? { dispatcher: fetchAgent } : {}),",
651
- ) ||
652
- patchedText.includes(
653
- "...(typeof agent?.dispatch === 'function' ? { dispatcher: agent } : {}),",
654
- ) ||
655
- (patchedText.includes(
656
- "const dispatcher = typeof agent?.dispatch === 'function' ? agent : undefined;",
657
- ) &&
658
- patchedText.includes("...(dispatcher ? { dispatcher } : {}),"));
659
- const legacyDispatcherPatchable =
660
- patchedText.includes(BAILEYS_MEDIA_DISPATCHER_NEEDLE) &&
661
- patchedText.includes(BAILEYS_MEDIA_DISPATCHER_HEADER_NEEDLE);
662
- const uploadWithFetchDispatcherPatchable = patchedText.includes(
663
- BAILEYS_MEDIA_UPLOAD_WITH_FETCH_DISPATCHER_NEEDLE,
664
- );
665
- let dispatcherResolved = dispatcherAlreadyPatched;
666
-
667
- if (!dispatcherResolved && legacyDispatcherPatchable) {
668
- patchedText = patchedText
669
- .replace(BAILEYS_MEDIA_DISPATCHER_NEEDLE, BAILEYS_MEDIA_DISPATCHER_REPLACEMENT)
670
- .replace(
671
- BAILEYS_MEDIA_DISPATCHER_HEADER_NEEDLE,
672
- BAILEYS_MEDIA_DISPATCHER_HEADER_REPLACEMENT,
673
- );
674
- applied = true;
675
- dispatcherResolved = true;
676
- }
677
-
678
- if (!dispatcherResolved && uploadWithFetchDispatcherPatchable) {
679
- patchedText = patchedText.replace(
680
- BAILEYS_MEDIA_UPLOAD_WITH_FETCH_DISPATCHER_NEEDLE,
681
- BAILEYS_MEDIA_UPLOAD_WITH_FETCH_DISPATCHER_REPLACEMENT,
682
- );
683
- applied = true;
684
- dispatcherResolved = true;
685
- }
686
-
687
- if (!dispatcherResolved) {
688
- return { applied: false, reason: "unexpected_content", targetPath };
689
- }
690
-
691
- if (!applied) {
692
- return { applied: false, reason: "already_patched" };
693
- }
694
- const tempPath = createTempPath(targetPath);
695
- const tempFd = openFile(tempPath, "wx", initialTargetValidation.mode);
696
- let tempFdClosed = false;
697
- try {
698
- writeFile(tempFd, patchedText, "utf8");
699
- closeFile(tempFd);
700
- tempFdClosed = true;
701
- const finalTargetValidation = validateTargetPath();
702
- if (!finalTargetValidation.ok) {
703
- return { applied: false, reason: finalTargetValidation.reason, targetPath };
704
- }
705
- renameFile(tempPath, targetPath);
706
- chmodFile(targetPath, initialTargetValidation.mode);
707
- } finally {
708
- if (!tempFdClosed) {
709
- try {
710
- closeFile(tempFd);
711
- } catch {
712
- // ignore failed-open cleanup
713
- }
714
- }
715
- removePath(tempPath, { force: true });
716
- }
717
- return { applied: true, reason: "patched", targetPath };
718
- } catch (error) {
719
- return {
720
- applied: false,
721
- reason: "error",
722
- targetPath,
723
- error: error instanceof Error ? error.message : String(error),
724
- };
725
- }
726
- }
727
-
728
- function applyBundledPluginRuntimeHotfixes(params = {}) {
729
- const log = params.log ?? console;
730
- const baileysResult = applyBaileysEncryptedStreamFinishHotfix(params);
731
- if (baileysResult.applied) {
732
- log.log("[postinstall] patched baileys runtime hotfixes");
733
- return;
734
- }
735
- if (baileysResult.reason !== "missing" && baileysResult.reason !== "already_patched") {
736
- log.warn(`[postinstall] could not patch baileys runtime hotfixes: ${baileysResult.reason}`);
737
- }
738
- }
739
-
740
- function resolveDistModuleUrl(packageRoot, distPath) {
741
- return pathToFileURL(join(packageRoot, distPath)).href;
742
- }
743
-
744
- async function importInstalledDistModule(params, distPath) {
745
- const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;
746
- const pathExists = params.existsSync ?? existsSync;
747
- const modulePath = join(packageRoot, distPath);
748
- if (!pathExists(modulePath)) {
749
- return null;
750
- }
751
- const importModule = params.importModule ?? ((specifier) => import(specifier));
752
- return await importModule(resolveDistModuleUrl(packageRoot, distPath));
753
- }
754
-
755
- export async function runPluginRegistryPostinstallMigration(params = {}) {
756
- const log = params.log ?? console;
757
- const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;
758
- const env = params.env ?? process.env;
759
-
760
- if (hasEnvFlag(env, DISABLE_PLUGIN_REGISTRY_MIGRATION_ENV)) {
761
- return { status: "disabled", migrated: false, reason: "disabled-env" };
762
- }
763
-
764
- try {
765
- const migrationModule = await importInstalledDistModule(
766
- params,
767
- "dist/commands/doctor/shared/plugin-registry-migration.js",
768
- );
769
- if (!migrationModule) {
770
- return { status: "skipped", reason: "missing-dist-entry" };
771
- }
772
- if (typeof migrationModule.migratePluginRegistryForInstall !== "function") {
773
- return { status: "skipped", reason: "missing-dist-contract" };
774
- }
775
-
776
- const result = await migrationModule.migratePluginRegistryForInstall({
777
- env,
778
- packageRoot,
779
- });
780
- for (const warning of result.preflight?.deprecationWarnings ?? []) {
781
- log.warn(`[postinstall] ${warning}`);
782
- }
783
- if (result.migrated) {
784
- log.log(
785
- `[postinstall] migrated plugin registry: ${result.current.plugins.length} plugin(s) indexed`,
786
- );
787
- }
788
- return result;
789
- } catch (error) {
790
- const message = error instanceof Error ? error.message : String(error);
791
- log.warn(`[postinstall] could not migrate plugin registry: ${message}`);
792
- return { status: "failed", error: message };
793
- }
794
- }
795
-
796
- export function isSourceCheckoutRoot(params) {
797
- const pathExists = params.existsSync ?? existsSync;
798
- const hasPostinstallInventory = pathExists(join(params.packageRoot, DIST_INVENTORY_PATH));
799
- return (
800
- (pathExists(join(params.packageRoot, ".git")) ||
801
- (pathExists(join(params.packageRoot, "pnpm-workspace.yaml")) && !hasPostinstallInventory)) &&
802
- pathExists(join(params.packageRoot, "src")) &&
803
- pathExists(join(params.packageRoot, "extensions"))
804
- );
805
- }
806
-
807
- export function pruneBundledPluginSourceNodeModules(params = {}) {
808
- const extensionsDir = params.extensionsDir ?? join(DEFAULT_PACKAGE_ROOT, "extensions");
809
- const pathExists = params.existsSync ?? existsSync;
810
- const readDir = params.readdirSync ?? readdirSync;
811
- const removePath = params.rmSync ?? rmSync;
812
-
813
- if (!pathExists(extensionsDir)) {
814
- return;
815
- }
816
-
817
- for (const entry of readDir(extensionsDir, { withFileTypes: true })) {
818
- if (!entry.isDirectory() || entry.isSymbolicLink()) {
819
- continue;
820
- }
821
-
822
- const pluginDir = join(extensionsDir, entry.name);
823
- if (!pathExists(join(pluginDir, "package.json"))) {
824
- continue;
825
- }
826
-
827
- removePath(join(pluginDir, "node_modules"), { recursive: true, force: true });
828
- }
829
- }
830
-
831
- function shouldRunBundledPluginPostinstall(params) {
832
- if (params.env?.[DISABLE_POSTINSTALL_ENV]?.trim()) {
833
- return false;
834
- }
835
- if (!params.existsSync(params.extensionsDir)) {
836
- return false;
837
- }
838
- return true;
839
- }
840
-
841
- function isCompileCachePrunePermissionDenied(error) {
842
- return error?.code === "EACCES" || error?.code === "EPERM";
843
- }
844
-
845
- export function pruneFengMingCompileCache(params = {}) {
846
- const env = params.env ?? process.env;
847
- const pathExists = params.existsSync ?? existsSync;
848
- const readDir = params.readdirSync ?? readdirSync;
849
- const remove = params.rmSync ?? rmSync;
850
- const log = params.log ?? console;
851
- const baseDirs = [
852
- env.NODE_DISABLE_COMPILE_CACHE ? "" : env.NODE_COMPILE_CACHE,
853
- join(tmpdir(), "node-compile-cache"),
854
- ].filter((value, index, values) => value && values.indexOf(value) === index);
855
-
856
- for (const baseDir of baseDirs) {
857
- if (!pathExists(baseDir)) {
858
- continue;
859
- }
860
- try {
861
- for (const entry of readDir(baseDir, { withFileTypes: true })) {
862
- if (!entry.isDirectory() || !NODE_COMPILE_CACHE_VERSION_DIR_RE.test(entry.name)) {
863
- continue;
864
- }
865
- try {
866
- remove(join(baseDir, entry.name), {
867
- recursive: true,
868
- force: true,
869
- maxRetries: 2,
870
- retryDelay: 100,
871
- });
872
- } catch (error) {
873
- if (isCompileCachePrunePermissionDenied(error)) {
874
- continue;
875
- }
876
- log.warn?.(`[postinstall] could not prune FengMing compile cache: ${String(error)}`);
877
- }
878
- }
879
- } catch (error) {
880
- if (isCompileCachePrunePermissionDenied(error)) {
881
- continue;
882
- }
883
- log.warn?.(`[postinstall] could not prune FengMing compile cache: ${String(error)}`);
884
- }
885
- }
886
- }
887
-
888
- export function runBundledPluginPostinstall(params = {}) {
889
- const env = params.env ?? process.env;
890
- const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;
891
- const extensionsDir = params.extensionsDir ?? join(packageRoot, "dist", "extensions");
892
- const pathExists = params.existsSync ?? existsSync;
893
- const log = params.log ?? console;
894
- if (env?.[DISABLE_POSTINSTALL_ENV]?.trim()) {
895
- return;
896
- }
897
- pruneFengMingCompileCache({
898
- env,
899
- existsSync: pathExists,
900
- rmSync: params.rmSync,
901
- log,
902
- });
903
- if (isSourceCheckoutRoot({ packageRoot, existsSync: pathExists })) {
904
- try {
905
- pruneBundledPluginSourceNodeModules({
906
- extensionsDir: join(packageRoot, "extensions"),
907
- existsSync: pathExists,
908
- readdirSync: params.readdirSync,
909
- rmSync: params.rmSync,
910
- });
911
- } catch (e) {
912
- log.warn(`[postinstall] could not prune bundled plugin source node_modules: ${String(e)}`);
913
- }
914
- applyBundledPluginRuntimeHotfixes({
915
- packageRoot,
916
- existsSync: pathExists,
917
- readFileSync: params.readFileSync,
918
- writeFileSync: params.writeFileSync,
919
- log,
920
- });
921
- return;
922
- }
923
- pruneLegacyPluginRuntimeDepsState({
924
- env,
925
- packageRoot,
926
- existsSync: pathExists,
927
- lstatSync: params.lstatSync,
928
- readlinkSync: params.readlinkSync,
929
- rmSync: params.rmSync,
930
- unlinkSync: params.unlinkSync,
931
- log,
932
- homedir: params.homedir,
933
- });
934
- pruneInstalledPackageDist({
935
- packageRoot,
936
- existsSync: pathExists,
937
- readFileSync: params.readFileSync,
938
- readdirSync: params.readdirSync,
939
- rmSync: params.rmSync,
940
- log,
941
- });
942
- if (
943
- !shouldRunBundledPluginPostinstall({
944
- env,
945
- extensionsDir,
946
- packageRoot,
947
- existsSync: pathExists,
948
- })
949
- ) {
950
- return;
951
- }
952
- applyBundledPluginRuntimeHotfixes({
953
- packageRoot,
954
- existsSync: pathExists,
955
- readFileSync: params.readFileSync,
956
- writeFileSync: params.writeFileSync,
957
- log,
958
- });
959
- }
960
-
961
- export function isDirectPostinstallInvocation(params = {}) {
962
- const entryPath = params.entryPath ?? process.argv[1];
963
- if (!entryPath) {
964
- return false;
965
- }
966
- const modulePath = params.modulePath ?? fileURLToPath(import.meta.url);
967
- const resolveRealPath = params.realpathSync ?? realpathSync;
968
- try {
969
- return resolveRealPath(entryPath) === resolveRealPath(modulePath);
970
- } catch {
971
- return pathToFileURL(entryPath).href === pathToFileURL(modulePath).href;
972
- }
973
- }
974
-
975
- if (isDirectPostinstallInvocation()) {
976
- runBundledPluginPostinstall();
977
- await runPluginRegistryPostinstallMigration();
978
- }