@spacebar_ai/moldclaw-core 2026.3.14 → 2026.3.16

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 (1074) hide show
  1. package/README.md +108 -3
  2. package/dist/account-id-plS5L20e.d.ts +1 -0
  3. package/dist/accounts-BAYVGC2k.js +109 -0
  4. package/dist/accounts-DrjRgReV.d.ts +103 -0
  5. package/dist/acp-cli-at_UYEOS.js +2088 -0
  6. package/dist/acpx-Chy1GQ_k.d.ts +5 -0
  7. package/dist/actions.runtime-C0F7dMfO.js +114 -0
  8. package/dist/actions.runtime-caI2LG9o.js +128 -0
  9. package/dist/agent-media-payload-CkpAqaOh.d.ts +16 -0
  10. package/dist/agents-B98yPGc5.js +853 -0
  11. package/dist/agents-BrLr08L3.js +217 -0
  12. package/dist/allow-from-BIwT4dl7.d.ts +42 -0
  13. package/dist/allow-list-CHt7yvAf.js +81 -0
  14. package/dist/allowlist-CxQo2wQc.js +142 -0
  15. package/dist/allowlist-resolution-B7ib7gye.d.ts +17 -0
  16. package/dist/api-Co7TNHbL.js +6953 -0
  17. package/dist/api-cEQ_ql_8.js +112 -0
  18. package/dist/audit-AnKnnlaZ.js +787 -0
  19. package/dist/audit-channel.collect.runtime-CAk1DFQ3.js +600 -0
  20. package/dist/audit-channel.runtime-5phdZp_m.js +116 -0
  21. package/dist/audit-extra.async-B8ZXFxic.js +813 -0
  22. package/dist/audit-hdKa3D-u.js +54 -0
  23. package/dist/audit-membership-runtime-CJV5XvGU.js +157 -0
  24. package/dist/audit.deep.runtime-DNMcRQrp.js +24 -0
  25. package/dist/audit.nondeep.runtime-DhNDL6yM.js +831 -0
  26. package/dist/audit.runtime-Bx7uWEh8.js +113 -0
  27. package/dist/auth-choice-C37W9MA7.js +268 -0
  28. package/dist/auth-choice-CNppOY_V.js +117 -0
  29. package/dist/auth-choice-XYFnp6fI.js +502 -0
  30. package/dist/auth-choice-options-D6oZY4Xo.js +123 -0
  31. package/dist/auth-choice-prompt-BhRqchJx.js +110 -0
  32. package/dist/auth-choice-prompt-C1xv0N08.js +36 -0
  33. package/dist/auth-choice.plugin-providers.runtime-DhLEtbmR.js +114 -0
  34. package/dist/auth-profiles-9zZdaXJK.js +127756 -0
  35. package/dist/auth-profiles.runtime-HONFDgiu.js +111 -0
  36. package/dist/bluebubbles-BY8JhO4y.js +64 -0
  37. package/dist/bluebubbles-CQjEnzK_.d.ts +6 -0
  38. package/dist/bluebubbles-RmcKgkBa.d.ts +45 -0
  39. package/dist/boolean-param-F1sMwnPu.d.ts +5 -0
  40. package/dist/bot-BGh-ATV7.d.ts +478 -0
  41. package/dist/brave-CljenznH.js +24 -0
  42. package/dist/browser-cli-CX8i0wf0.js +1492 -0
  43. package/dist/build-info.json +3 -3
  44. package/dist/bundled/boot-md/handler.d.ts +6 -0
  45. package/dist/bundled/boot-md/handler.js +26 -26
  46. package/dist/bundled/bootstrap-extra-files/handler.d.ts +6 -0
  47. package/dist/bundled/command-logger/handler.d.ts +9 -0
  48. package/dist/bundled/session-memory/handler.d.ts +9 -0
  49. package/dist/bundled/session-memory/handler.js +27 -27
  50. package/dist/call-Bc257L16.js +37 -0
  51. package/dist/call-DYFR7oGy.js +639 -0
  52. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  53. package/dist/channel-Bd-igGEW.js +803 -0
  54. package/dist/channel-BgRMb6bZ.js +575 -0
  55. package/dist/channel-BtcLrU6J.js +1598 -0
  56. package/dist/channel-Bwf6m_hD.js +538 -0
  57. package/dist/channel-C7-kgDBd.js +562 -0
  58. package/dist/channel-CEXOAxIc.js +949 -0
  59. package/dist/channel-CpZ3p9MJ.js +226 -0
  60. package/dist/channel-CqBlN6A2.js +619 -0
  61. package/dist/channel-DKhfHW4U.js +352 -0
  62. package/dist/channel-DS3t_KdJ2.js +316 -0
  63. package/dist/channel-DY24FA1v.js +4681 -0
  64. package/dist/channel-DYFGmImJ.js +542 -0
  65. package/dist/channel-DcyIqX5p.js +207 -0
  66. package/dist/channel-J-2XcAli.js +214 -0
  67. package/dist/channel-N616f4gZ.js +306 -0
  68. package/dist/channel-NY7aU2Gj.js +397 -0
  69. package/dist/channel-PNI8BOmm.js +1321 -0
  70. package/dist/channel-UcXepDJs.js +943 -0
  71. package/dist/channel-account-context-CL3hEq1j.js +103 -0
  72. package/dist/channel-config-schema-Q2nzcCCR.d.ts +1 -0
  73. package/dist/channel-jA_jodJo.js +920 -0
  74. package/dist/channel-options-CtgU5qkG.js +50 -0
  75. package/dist/channel-policy-7wXDp6d3.d.ts +1 -0
  76. package/dist/channel-rGI8uig4.js +497 -0
  77. package/dist/channel-summary-DGJZXo0r.js +106 -0
  78. package/dist/channel.runtime--WZvlNJM.js +413 -0
  79. package/dist/channel.runtime-B0ct42DL.js +122 -0
  80. package/dist/channel.runtime-BEZUZrYB.js +177 -0
  81. package/dist/channel.runtime-BMuWmsIC.js +166 -0
  82. package/dist/channel.runtime-BtvHP0po.js +4006 -0
  83. package/dist/channel.runtime-Cwf993pX.js +194 -0
  84. package/dist/channel.runtime-Cy4lEpTX.js +174 -0
  85. package/dist/channel.runtime-DAz6axda.js +865 -0
  86. package/dist/channel.runtime-DdQ2mOVh.js +236 -0
  87. package/dist/channel.runtime-Dy3HPgOU.js +399 -0
  88. package/dist/channel.runtime-iqfC25k7.js +213 -0
  89. package/dist/channel.setup-B4VYMZlQ.js +9 -0
  90. package/dist/channel.setup-BohGbCbI.js +57 -0
  91. package/dist/channel.setup-Bq2AQqqc.js +6 -0
  92. package/dist/channel.setup-BxiSfLp1.js +8 -0
  93. package/dist/channel.setup-DOUS6fjO.js +8 -0
  94. package/dist/channel.setup-DXhdYU3g.js +9 -0
  95. package/dist/channel.setup-N51CgfNy.js +11 -0
  96. package/dist/channels/plugins/actions/discord.d.ts +3 -0
  97. package/dist/channels/plugins/actions/discord.js +26 -26
  98. package/dist/channels/plugins/actions/signal.d.ts +2 -0
  99. package/dist/channels/plugins/actions/signal.js +26 -26
  100. package/dist/channels/plugins/actions/telegram.d.ts +3 -0
  101. package/dist/channels/plugins/actions/telegram.js +26 -26
  102. package/dist/channels/plugins/agent-tools/whatsapp-login.d.ts +4 -0
  103. package/dist/channels/plugins/agent-tools/whatsapp-login.js +26 -26
  104. package/dist/channels-CueeFf0q.js +404 -0
  105. package/dist/channels-PheAd73E.js +1113 -0
  106. package/dist/channels-cli-CXzVF84v.js +286 -0
  107. package/dist/channels-status-issues-BjWBQHhU.js +16 -0
  108. package/dist/chat-type-BlSN0vo4.d.ts +5 -0
  109. package/dist/clawbot-cli-BBehDXW1.js +113 -0
  110. package/dist/cli/daemon-cli.d.ts +58 -0
  111. package/dist/cli/daemon-cli.js +1 -1
  112. package/dist/cli-CIm7d5Id.js +149 -0
  113. package/dist/command-format-pq3tS8t2.d.ts +4 -0
  114. package/dist/command-registry-CDkp__KH.js +13 -0
  115. package/dist/command-registry-DSEkUBW1.js +212 -0
  116. package/dist/command-secret-gateway-CqP_o0n8.js +106 -0
  117. package/dist/compact.runtime-Qm_csEtG.js +111 -0
  118. package/dist/completion-cli-Ch1sgSLQ.js +445 -0
  119. package/dist/completion-cli-vF067Tso.js +16 -0
  120. package/dist/config-B2W1zTP1.js +44 -0
  121. package/dist/config-CMhKplgO.js +938 -0
  122. package/dist/config-DchtRsvs.js +30 -0
  123. package/dist/config-cli-C41d88_c.js +428 -0
  124. package/dist/config-guard-B_vjkXCQ.js +117 -0
  125. package/dist/config-schema-pPBCF4hz.js +31 -0
  126. package/dist/config-validation-6om9cBUx.js +262 -0
  127. package/dist/config-value-Dl3XEpA6.js +132 -0
  128. package/dist/configure-BxzvDSzu.js +1100 -0
  129. package/dist/configure-CLMLoWAn.js +238 -0
  130. package/dist/control-ui-shared-E8Nz6uKZ.js +29 -0
  131. package/dist/core-Cd3fMFKq.d.ts +87 -0
  132. package/dist/credentials-yYt6VWCq.js +268 -0
  133. package/dist/cron-cli-CA3lV3kh.js +634 -0
  134. package/dist/daemon-cli-BtQuIXEk.js +339 -0
  135. package/dist/daemon-install-BWKGzgMm.js +175 -0
  136. package/dist/deliver-CgMNmfTy.js +106 -0
  137. package/dist/deliver-runtime-Bn1KWoiQ.js +106 -0
  138. package/dist/devices-cli-D601npiL.js +340 -0
  139. package/dist/diagnostic-CkiYEGqt.js +310 -0
  140. package/dist/diffs-B5tZ8Coj.d.ts +1 -0
  141. package/dist/directory-cli-skEV8MT7.js +306 -0
  142. package/dist/directory-config-helpers-B-tiBKIv.d.ts +38 -0
  143. package/dist/directory-runtime-BEJ2fCIR.d.ts +1 -0
  144. package/dist/directory.static-CnyzoWbV.js +44 -0
  145. package/dist/discord-B_gbzPti.js +109 -0
  146. package/dist/discovery-CqI-e_Mv.js +48 -0
  147. package/dist/dm-policy-shared-nybkS1uP.d.ts +95 -0
  148. package/dist/dns-cli-Cjes3Ruw.js +216 -0
  149. package/dist/docs-cli-C3g3Gi_d.js +173 -0
  150. package/dist/doctor-completion-TvgV4SZH.js +90 -0
  151. package/dist/doctor-config-flow-0w9Ux7V8.js +107 -0
  152. package/dist/doctor-config-flow-DLzr8W7Y.js +2437 -0
  153. package/dist/enable-VYzv8b2z.js +24 -0
  154. package/dist/entry.d.ts +7 -0
  155. package/dist/entry.js +1 -1
  156. package/dist/env-overrides-DYVIkuvN.js +434 -0
  157. package/dist/env-overrides.runtime-6kijpIuu.js +17 -0
  158. package/dist/exec-approvals-cli-D_lkTG-l.js +419 -0
  159. package/dist/exec-sVmouhA9.d.ts +39 -0
  160. package/dist/extensions/acpx/index.d.ts +11 -0
  161. package/dist/extensions/acpx/index.js +1 -1
  162. package/dist/extensions/amazon-bedrock/index.d.ts +11 -0
  163. package/dist/extensions/anthropic/index.d.ts +11 -0
  164. package/dist/extensions/anthropic/index.js +26 -26
  165. package/dist/extensions/bluebubbles/index.d.ts +11 -0
  166. package/dist/extensions/bluebubbles/index.js +30 -30
  167. package/dist/extensions/bluebubbles/setup-entry.d.ts +59 -0
  168. package/dist/extensions/bluebubbles/setup-entry.js +30 -30
  169. package/dist/extensions/brave/index.d.ts +11 -0
  170. package/dist/extensions/brave/index.js +2 -2
  171. package/dist/extensions/byteplus/index.d.ts +11 -0
  172. package/dist/extensions/byteplus/index.js +26 -26
  173. package/dist/extensions/cloudflare-ai-gateway/index.d.ts +11 -0
  174. package/dist/extensions/cloudflare-ai-gateway/index.js +27 -27
  175. package/dist/extensions/copilot-proxy/index.d.ts +11 -0
  176. package/dist/extensions/device-pair/index.d.ts +12 -0
  177. package/dist/extensions/diagnostics-otel/index.d.ts +11 -0
  178. package/dist/extensions/diffs/index.d.ts +11 -0
  179. package/dist/extensions/discord/index.d.ts +11 -0
  180. package/dist/extensions/discord/index.js +31 -31
  181. package/dist/extensions/discord/setup-entry.d.ts +7 -0
  182. package/dist/extensions/discord/setup-entry.js +29 -29
  183. package/dist/extensions/elevenlabs/index.d.ts +11 -0
  184. package/dist/extensions/elevenlabs/index.js +26 -26
  185. package/dist/extensions/feishu/index.d.ts +229 -0
  186. package/dist/extensions/feishu/index.js +31 -31
  187. package/dist/extensions/feishu/setup-entry.d.ts +9 -0
  188. package/dist/extensions/feishu/setup-entry.js +28 -28
  189. package/dist/extensions/firecrawl/index.d.ts +11 -0
  190. package/dist/extensions/firecrawl/index.js +26 -26
  191. package/dist/extensions/github-copilot/index.d.ts +11 -0
  192. package/dist/extensions/github-copilot/index.js +27 -27
  193. package/dist/extensions/google/index.d.ts +11 -0
  194. package/dist/extensions/google/index.js +26 -26
  195. package/dist/extensions/googlechat/index.d.ts +11 -0
  196. package/dist/extensions/googlechat/index.js +30 -30
  197. package/dist/extensions/googlechat/setup-entry.d.ts +19 -0
  198. package/dist/extensions/googlechat/setup-entry.js +30 -30
  199. package/dist/extensions/huggingface/index.d.ts +11 -0
  200. package/dist/extensions/huggingface/index.js +26 -26
  201. package/dist/extensions/imessage/index.d.ts +11 -0
  202. package/dist/extensions/imessage/index.js +30 -30
  203. package/dist/extensions/imessage/setup-entry.d.ts +7 -0
  204. package/dist/extensions/imessage/setup-entry.js +30 -30
  205. package/dist/extensions/irc/index.d.ts +11 -0
  206. package/dist/extensions/irc/index.js +29 -29
  207. package/dist/extensions/irc/setup-entry.d.ts +8 -0
  208. package/dist/extensions/irc/setup-entry.js +29 -29
  209. package/dist/extensions/kakao-talkchannel/index.d.ts +19 -0
  210. package/dist/extensions/kakao-talkchannel/index.js +1762 -0
  211. package/dist/extensions/kakao-talkchannel/moldclaw.plugin.json +111 -0
  212. package/dist/extensions/kakao-talkchannel/package.json +12 -0
  213. package/dist/extensions/kilocode/index.d.ts +11 -0
  214. package/dist/extensions/kilocode/index.js +26 -26
  215. package/dist/extensions/kimi-coding/index.d.ts +11 -0
  216. package/dist/extensions/kimi-coding/index.js +26 -26
  217. package/dist/extensions/line/index.d.ts +11 -0
  218. package/dist/extensions/line/index.js +28 -28
  219. package/dist/extensions/line/setup-entry.d.ts +7 -0
  220. package/dist/extensions/line/setup-entry.js +28 -28
  221. package/dist/extensions/llm-task/index.d.ts +11 -0
  222. package/dist/extensions/llm-task/index.js +28 -28
  223. package/dist/extensions/lobster/index.d.ts +11 -0
  224. package/dist/extensions/matrix/index.d.ts +11 -0
  225. package/dist/extensions/matrix/index.js +31 -31
  226. package/dist/extensions/matrix/setup-entry.d.ts +20 -0
  227. package/dist/extensions/matrix/setup-entry.js +31 -31
  228. package/dist/extensions/mattermost/index.d.ts +11 -0
  229. package/dist/extensions/mattermost/index.js +28 -28
  230. package/dist/extensions/mattermost/setup-entry.d.ts +88 -0
  231. package/dist/extensions/mattermost/setup-entry.js +28 -28
  232. package/dist/extensions/memory-core/index.d.ts +11 -0
  233. package/dist/extensions/memory-lancedb/index.d.ts +25 -0
  234. package/dist/extensions/microsoft/index.d.ts +11 -0
  235. package/dist/extensions/microsoft/index.js +26 -26
  236. package/dist/extensions/minimax/index.d.ts +11 -0
  237. package/dist/extensions/minimax/index.js +26 -26
  238. package/dist/extensions/mistral/index.d.ts +11 -0
  239. package/dist/extensions/mistral/index.js +26 -26
  240. package/dist/extensions/modelstudio/index.d.ts +11 -0
  241. package/dist/extensions/modelstudio/index.js +26 -26
  242. package/dist/extensions/moonshot/index.d.ts +11 -0
  243. package/dist/extensions/moonshot/index.js +26 -26
  244. package/dist/extensions/msteams/index.d.ts +11 -0
  245. package/dist/extensions/msteams/index.js +31 -31
  246. package/dist/extensions/msteams/setup-entry.d.ts +11 -0
  247. package/dist/extensions/msteams/setup-entry.js +31 -31
  248. package/dist/extensions/nextcloud-talk/index.d.ts +11 -0
  249. package/dist/extensions/nextcloud-talk/index.js +28 -28
  250. package/dist/extensions/nextcloud-talk/setup-entry.d.ts +60 -0
  251. package/dist/extensions/nextcloud-talk/setup-entry.js +28 -28
  252. package/dist/extensions/nostr/index.d.ts +11 -0
  253. package/dist/extensions/nostr/index.js +28 -28
  254. package/dist/extensions/nostr/setup-entry.d.ts +49 -0
  255. package/dist/extensions/nostr/setup-entry.js +28 -28
  256. package/dist/extensions/nvidia/index.d.ts +11 -0
  257. package/dist/extensions/ollama/index.d.ts +11 -0
  258. package/dist/extensions/open-prose/index.d.ts +11 -0
  259. package/dist/extensions/openai/index.d.ts +11 -0
  260. package/dist/extensions/openai/index.js +26 -26
  261. package/dist/extensions/opencode/index.d.ts +11 -0
  262. package/dist/extensions/opencode/index.js +26 -26
  263. package/dist/extensions/opencode-go/index.d.ts +11 -0
  264. package/dist/extensions/opencode-go/index.js +26 -26
  265. package/dist/extensions/openrouter/index.d.ts +11 -0
  266. package/dist/extensions/openrouter/index.js +26 -26
  267. package/dist/extensions/openshell/index.d.ts +11 -0
  268. package/dist/extensions/openshell/index.js +26 -26
  269. package/dist/extensions/perplexity/index.d.ts +11 -0
  270. package/dist/extensions/perplexity/index.js +2 -2
  271. package/dist/extensions/phone-control/index.d.ts +12 -0
  272. package/dist/extensions/qianfan/index.d.ts +11 -0
  273. package/dist/extensions/qianfan/index.js +26 -26
  274. package/dist/extensions/qwen-portal-auth/index.d.ts +12 -0
  275. package/dist/extensions/qwen-portal-auth/index.js +26 -26
  276. package/dist/extensions/sglang/index.d.ts +11 -0
  277. package/dist/extensions/sglang/index.js +26 -26
  278. package/dist/extensions/signal/index.d.ts +11 -0
  279. package/dist/extensions/signal/index.js +29 -29
  280. package/dist/extensions/signal/setup-entry.d.ts +7 -0
  281. package/dist/extensions/signal/setup-entry.js +29 -29
  282. package/dist/extensions/slack/index.d.ts +11 -0
  283. package/dist/extensions/slack/index.js +30 -30
  284. package/dist/extensions/slack/setup-entry.d.ts +7 -0
  285. package/dist/extensions/slack/setup-entry.js +29 -29
  286. package/dist/extensions/synology-chat/index.d.ts +11 -0
  287. package/dist/extensions/synology-chat/index.js +28 -28
  288. package/dist/extensions/synology-chat/setup-entry.d.ts +138 -0
  289. package/dist/extensions/synology-chat/setup-entry.js +28 -28
  290. package/dist/extensions/synthetic/index.d.ts +11 -0
  291. package/dist/extensions/synthetic/index.js +26 -26
  292. package/dist/extensions/talk-voice/index.d.ts +12 -0
  293. package/dist/extensions/talk-voice/index.js +26 -26
  294. package/dist/extensions/telegram/index.d.ts +11 -0
  295. package/dist/extensions/telegram/index.js +29 -29
  296. package/dist/extensions/telegram/setup-entry.d.ts +7 -0
  297. package/dist/extensions/telegram/setup-entry.js +28 -28
  298. package/dist/extensions/thread-ownership/index.d.ts +12 -0
  299. package/dist/extensions/tlon/index.d.ts +11 -0
  300. package/dist/extensions/tlon/index.js +28 -28
  301. package/dist/extensions/tlon/setup-entry.d.ts +7 -0
  302. package/dist/extensions/tlon/setup-entry.js +28 -28
  303. package/dist/extensions/together/index.d.ts +11 -0
  304. package/dist/extensions/together/index.js +26 -26
  305. package/dist/extensions/twitch/index.d.ts +39 -0
  306. package/dist/extensions/twitch/index.js +28 -28
  307. package/dist/extensions/venice/index.d.ts +11 -0
  308. package/dist/extensions/venice/index.js +26 -26
  309. package/dist/extensions/vercel-ai-gateway/index.d.ts +11 -0
  310. package/dist/extensions/vercel-ai-gateway/index.js +26 -26
  311. package/dist/extensions/vllm/index.d.ts +11 -0
  312. package/dist/extensions/vllm/index.js +26 -26
  313. package/dist/extensions/voice-call/index.d.ts +11 -0
  314. package/dist/extensions/voice-call/index.js +26 -26
  315. package/dist/extensions/volcengine/index.d.ts +11 -0
  316. package/dist/extensions/volcengine/index.js +26 -26
  317. package/dist/extensions/whatsapp/index.d.ts +11 -0
  318. package/dist/extensions/whatsapp/index.js +29 -29
  319. package/dist/extensions/whatsapp/setup-entry.d.ts +7 -0
  320. package/dist/extensions/whatsapp/setup-entry.js +29 -29
  321. package/dist/extensions/xai/index.d.ts +11 -0
  322. package/dist/extensions/xai/index.js +26 -26
  323. package/dist/extensions/xiaomi/index.d.ts +11 -0
  324. package/dist/extensions/xiaomi/index.js +26 -26
  325. package/dist/extensions/zai/index.d.ts +11 -0
  326. package/dist/extensions/zai/index.js +26 -26
  327. package/dist/extensions/zalo/index.d.ts +11 -0
  328. package/dist/extensions/zalo/index.js +30 -30
  329. package/dist/extensions/zalo/setup-entry.d.ts +34 -0
  330. package/dist/extensions/zalo/setup-entry.js +30 -30
  331. package/dist/extensions/zalouser/index.d.ts +11 -0
  332. package/dist/extensions/zalouser/index.js +31 -31
  333. package/dist/extensions/zalouser/setup-entry.d.ts +42 -0
  334. package/dist/extensions/zalouser/setup-entry.js +31 -31
  335. package/dist/feishu-DCKEC3ao.d.ts +36 -0
  336. package/dist/gateway-cli-DN1Ii6J-.js +26432 -0
  337. package/dist/gateway-install-token-CJYFJBaC.js +163 -0
  338. package/dist/gateway-rpc-CroQg9MB.js +26 -0
  339. package/dist/gateway-runtime-D9FRZqKP.js +69 -0
  340. package/dist/googlechat-CBCkerAy.js +307 -0
  341. package/dist/googlechat-CSUNieHX.d.ts +12 -0
  342. package/dist/group-access-rSvkIglb.d.ts +61 -0
  343. package/dist/health-B6WwLJp4.js +570 -0
  344. package/dist/health-CAlJydXv.js +108 -0
  345. package/dist/history-BwNxb0sJ.d.ts +75 -0
  346. package/dist/hooks-BYlfU3Nf.d.ts +6 -0
  347. package/dist/hooks-cli-DuKmdo_H.js +995 -0
  348. package/dist/http-registry-DX_LVtuK.d.ts +20 -0
  349. package/dist/image-generation-DKkdRpve.d.ts +9 -0
  350. package/dist/imessage-7abjbe2Q.js +31 -0
  351. package/dist/imessage-DOH1yaDE.js +110 -0
  352. package/dist/inbound-envelope-CmvweL6U.d.ts +78 -0
  353. package/dist/inbound-reply-dispatch-BvnKTOec.js +71 -0
  354. package/dist/inbound-reply-dispatch-C7LjHRZN.d.ts +72 -0
  355. package/dist/index-DTQqfqj9.d.ts +1 -0
  356. package/dist/index.d.ts +27 -0
  357. package/dist/index.js +2 -2
  358. package/dist/infra/warning-filter.d.ts +10 -0
  359. package/dist/install-target-tXRD7VkM.js +574 -0
  360. package/dist/installs-C8fz8sm3.js +532 -0
  361. package/dist/io-C6XifaT4.js +9737 -0
  362. package/dist/io-C8awRnSW.js +28 -0
  363. package/dist/ipv4-d88_Jn2p.js +82 -0
  364. package/dist/irc-DpR6FXjN.js +672 -0
  365. package/dist/json-store-Sr_kk-II.d.ts +14 -0
  366. package/dist/keyed-async-queue-BA3BKukE.d.ts +19 -0
  367. package/dist/library-DOwowAGN.js +107 -0
  368. package/dist/lifecycle-core-BHHBoRTY.js +382 -0
  369. package/dist/line/accounts.d.ts +3 -0
  370. package/dist/line/send.d.ts +2 -0
  371. package/dist/line/send.js +4 -4
  372. package/dist/line/template-messages.d.ts +2 -0
  373. package/dist/line-8rsNbJCP.js +530 -0
  374. package/dist/line-D_cvIf6B.d.ts +75 -0
  375. package/dist/links-BOnvOj1z.d.ts +7 -0
  376. package/dist/llm-slug-generator-D9HjWtJT.js +67 -0
  377. package/dist/llm-slug-generator.d.ts +12 -0
  378. package/dist/llm-slug-generator.js +27 -27
  379. package/dist/logging-BhqLWxTD.js +13 -0
  380. package/dist/logging-DfaiL4OX.js +29 -0
  381. package/dist/login-qr-COBYR52w.js +233 -0
  382. package/dist/login-qr-xK4QIpPc.js +107 -0
  383. package/dist/logs-cli-RSSTw8L_.js +254 -0
  384. package/dist/manager-runtime-DL6JoSj9.js +106 -0
  385. package/dist/manager.runtime-Cbyhg1vB.js +710 -0
  386. package/dist/markdown-to-line-BTlEkOls.d.ts +91 -0
  387. package/dist/matrix-DX-jaB88.js +1490 -0
  388. package/dist/matrix-H6Yyj1QZ.d.ts +68 -0
  389. package/dist/matrix-J8s45tRw.js +1269 -0
  390. package/dist/mattermost-D75n6bRI.d.ts +6 -0
  391. package/dist/mcp-cli-CLc3_yCO.js +86 -0
  392. package/dist/media-understanding.runtime-BI0Lljbl.js +111 -0
  393. package/dist/memory-cli-CTp2cYrf.js +106 -0
  394. package/dist/method-scopes-Du8ODGFW.js +2586 -0
  395. package/dist/model-auth-markers-DEDakSUW.d.ts +20 -0
  396. package/dist/model-picker-CDBs7LJF.js +390 -0
  397. package/dist/model-picker-CRix4Wwv.js +107 -0
  398. package/dist/model-picker.runtime-CITyy3Rn.js +120 -0
  399. package/dist/model-suppression.runtime-Ce7D6QUT.js +111 -0
  400. package/dist/models-BK1eanuP.js +113 -0
  401. package/dist/models-X4Czy3uE.js +2514 -0
  402. package/dist/models-cli-C79Ulviy.js +304 -0
  403. package/dist/models-config-DALlu3S9.js +106 -0
  404. package/dist/models-config.providers.discovery-CSJ1STM1.d.ts +18 -0
  405. package/dist/monitor-B45a_RpX.js +3468 -0
  406. package/dist/monitor-C8KbJ-i0.js +767 -0
  407. package/dist/monitor-CIhrvegZ.js +3076 -0
  408. package/dist/monitor-CQut7klP.js +6823 -0
  409. package/dist/monitor-DZb5IJle.js +777 -0
  410. package/dist/monitor-DaFkdD27.js +108 -0
  411. package/dist/monitor-Do9Tp2Ii.js +110 -0
  412. package/dist/monitor-shared-CMK9cDOb.js +444 -0
  413. package/dist/msteams-A6H_wv5F.js +852 -0
  414. package/dist/net-DpMJgN-o.d.ts +19 -0
  415. package/dist/nextcloud-talk-f1pZ5Bge.d.ts +1 -0
  416. package/dist/node-cli-BXnmsjzL.js +2498 -0
  417. package/dist/node-resolve-CupmrA0Y.js +835 -0
  418. package/dist/nodes-cli-DZVrah_8.js +1375 -0
  419. package/dist/nostr-DMV534Ks.d.ts +7 -0
  420. package/dist/nostr-SAk3tjtR.js +8744 -0
  421. package/dist/npm-resolution-Dr9wssCY.js +60 -0
  422. package/dist/oauth-utils-DnyXdWU9.d.ts +10 -0
  423. package/dist/onboard-BE5pmb1g.js +589 -0
  424. package/dist/onboard-channels-3hNVY0E7.js +1241 -0
  425. package/dist/onboard-channels-vaO3nWLL.js +200 -0
  426. package/dist/onboard-custom-CI5uFyWH.js +571 -0
  427. package/dist/onboard-custom-eIvRswgv.js +109 -0
  428. package/dist/onboard-helpers-ChMWfUnl.js +335 -0
  429. package/dist/onboard-helpers-DRFi9oaD.js +108 -0
  430. package/dist/onboard-remote-BTspTgA4.js +112 -0
  431. package/dist/onboard-remote-so38yXlX.js +181 -0
  432. package/dist/onboard-search-DS0tZS24.js +297 -0
  433. package/dist/onboard-skills-B9DxCCiU.js +133 -0
  434. package/dist/onboard-skills-so0a_BJV.js +112 -0
  435. package/dist/outbound-media-BiJscGlR.js +11 -0
  436. package/dist/outbound-media-DJF-TuJu.d.ts +11 -0
  437. package/dist/pairing-access-CuiJP9xN.d.ts +21 -0
  438. package/dist/pairing-cli-DN0u1Cez.js +212 -0
  439. package/dist/parse-finite-number-B3FJTjyQ.d.ts +5 -0
  440. package/dist/perplexity-Bw1u3CAF.js +24 -0
  441. package/dist/persistent-dedupe-DR5Ka6BX.d.ts +26 -0
  442. package/dist/pi-model-discovery-runtime-iwKNCaYu.js +106 -0
  443. package/dist/pi-tools.before-tool-call.runtime-BM_N-JZe.js +380 -0
  444. package/dist/plugin-install--KVul05Z.js +184 -0
  445. package/dist/plugin-install-DVpPsLkS.js +112 -0
  446. package/dist/plugin-install-plan-Dwc6-coz.js +49 -0
  447. package/dist/plugin-registry-XRswugE9.js +108 -0
  448. package/dist/plugin-registry-jozQafRo.js +49 -0
  449. package/dist/plugin-sdk/account-resolution.js +26 -26
  450. package/dist/plugin-sdk/acp-runtime.js +26 -26
  451. package/dist/plugin-sdk/acpx.js +1 -1
  452. package/dist/plugin-sdk/agent-runtime.js +26 -26
  453. package/dist/plugin-sdk/bluebubbles.js +29 -29
  454. package/dist/plugin-sdk/channel-config-helpers.js +26 -26
  455. package/dist/plugin-sdk/channel-config-schema.js +2 -2
  456. package/dist/plugin-sdk/channel-policy.js +26 -26
  457. package/dist/plugin-sdk/channel-runtime.js +26 -26
  458. package/dist/plugin-sdk/compat.js +27 -27
  459. package/dist/plugin-sdk/config-runtime.js +28 -28
  460. package/dist/plugin-sdk/conversation-runtime.js +26 -26
  461. package/dist/plugin-sdk/discord.js +26 -26
  462. package/dist/plugin-sdk/feishu.js +27 -27
  463. package/dist/plugin-sdk/gateway-runtime.js +8 -8
  464. package/dist/plugin-sdk/googlechat.js +29 -29
  465. package/dist/plugin-sdk/image-generation-runtime.js +26 -26
  466. package/dist/plugin-sdk/image-generation.js +26 -26
  467. package/dist/plugin-sdk/imessage.js +27 -27
  468. package/dist/plugin-sdk/index.js +26 -26
  469. package/dist/plugin-sdk/infra-runtime.js +26 -26
  470. package/dist/plugin-sdk/irc.js +29 -29
  471. package/dist/plugin-sdk/line.js +27 -27
  472. package/dist/plugin-sdk/llm-task.js +26 -26
  473. package/dist/plugin-sdk/matrix.js +29 -29
  474. package/dist/plugin-sdk/mattermost.js +28 -28
  475. package/dist/plugin-sdk/media-runtime.js +26 -26
  476. package/dist/plugin-sdk/media-understanding-runtime.js +26 -26
  477. package/dist/plugin-sdk/media-understanding.js +26 -26
  478. package/dist/plugin-sdk/msteams.js +30 -30
  479. package/dist/plugin-sdk/nextcloud-talk.js +28 -28
  480. package/dist/plugin-sdk/nostr.js +27 -27
  481. package/dist/plugin-sdk/plugin-runtime.js +26 -26
  482. package/dist/plugin-sdk/provider-auth.js +28 -28
  483. package/dist/plugin-sdk/provider-setup.js +27 -27
  484. package/dist/plugin-sdk/provider-web-search.js +1 -1
  485. package/dist/plugin-sdk/qwen-portal-auth.js +26 -26
  486. package/dist/plugin-sdk/reply-history.js +26 -26
  487. package/dist/plugin-sdk/reply-runtime.js +26 -26
  488. package/dist/plugin-sdk/sandbox.js +26 -26
  489. package/dist/plugin-sdk/security-runtime.js +26 -26
  490. package/dist/plugin-sdk/self-hosted-provider-setup.js +27 -27
  491. package/dist/plugin-sdk/setup.js +27 -27
  492. package/dist/plugin-sdk/signal.js +26 -26
  493. package/dist/plugin-sdk/slack.js +26 -26
  494. package/dist/plugin-sdk/speech-runtime.js +26 -26
  495. package/dist/plugin-sdk/speech.js +26 -26
  496. package/dist/plugin-sdk/src/channels/plugins/setup-wizard-helpers.d.ts +3 -0
  497. package/dist/plugin-sdk/src/config/config-lock.d.ts +38 -0
  498. package/dist/plugin-sdk/src/config/config.d.ts +1 -1
  499. package/dist/plugin-sdk/src/config/io.d.ts +39 -0
  500. package/dist/plugin-sdk/src/config/types.gateway.d.ts +12 -0
  501. package/dist/plugin-sdk/src/config/types.secrets.d.ts +10 -0
  502. package/dist/plugin-sdk/src/config/zod-schema.d.ts +2 -0
  503. package/dist/plugin-sdk/src/gateway/credential-planner.d.ts +3 -1
  504. package/dist/plugin-sdk/src/secrets/provider-env-vars.d.ts +61 -0
  505. package/dist/plugin-sdk/src/secrets/sec1-placeholder.d.ts +181 -0
  506. package/dist/plugin-sdk/src/secrets/sec1-utils.d.ts +57 -0
  507. package/dist/plugin-sdk/synology-chat.js +27 -27
  508. package/dist/plugin-sdk/telegram.js +26 -26
  509. package/dist/plugin-sdk/text-runtime.js +4 -4
  510. package/dist/plugin-sdk/tlon.js +27 -27
  511. package/dist/plugin-sdk/twitch.js +26 -26
  512. package/dist/plugin-sdk/voice-call.js +26 -26
  513. package/dist/plugin-sdk/whatsapp.js +26 -26
  514. package/dist/plugin-sdk/zalo.js +30 -30
  515. package/dist/plugin-sdk/zalouser.js +29 -29
  516. package/dist/plugins/runtime/index.d.ts +22 -0
  517. package/dist/plugins/runtime/index.js +26 -26
  518. package/dist/plugins-C4PiDdjc.js +106 -0
  519. package/dist/plugins-cli-zhmliYNU.js +912 -0
  520. package/dist/policy-CcSolumc.js +143 -0
  521. package/dist/preflight-audio.runtime-BAbfqqzW.js +111 -0
  522. package/dist/probe-Bgt5c-cr.js +129 -0
  523. package/dist/probe-CPk5iGcg.js +47 -0
  524. package/dist/probe-DR4KRKXz.js +19 -0
  525. package/dist/probe-DnoCyJ_m.js +1793 -0
  526. package/dist/probe-VsLtK3vQ.js +6328 -0
  527. package/dist/probe-auth-BnsKrQt7.js +38 -0
  528. package/dist/probe-auth-DYdUG8l1.js +48 -0
  529. package/dist/program-8enYYBsc.js +247 -0
  530. package/dist/prompt-select-styled-DxBcUasv.js +2673 -0
  531. package/dist/provider-api-key-auth.runtime-DsLZyt6h.js +116 -0
  532. package/dist/provider-auth-choice-30EvRxqc.js +126 -0
  533. package/dist/provider-auth-choice-preference-DMr1WmRg.js +189 -0
  534. package/dist/provider-auth-choice.runtime-CI98BgQF.js +118 -0
  535. package/dist/provider-auth-guidance-WKDIi_wk.js +34 -0
  536. package/dist/provider-auth-result-Cs8wguSI.d.ts +18 -0
  537. package/dist/provider-models-EOys_Nvi.d.ts +867 -0
  538. package/dist/provider-ollama-setup-D89zlm9C.d.ts +32 -0
  539. package/dist/provider-onboard-BzOpgCLu.d.ts +40 -0
  540. package/dist/provider-runtime.runtime-Cm4as2KG.js +106 -0
  541. package/dist/provider-self-hosted-setup-Bmv_AQmw.d.ts +61 -0
  542. package/dist/provider-self-hosted-setup-CJwFVVB4.js +182 -0
  543. package/dist/provider-usage-CVNyLLDb.js +106 -0
  544. package/dist/provider-usage.types-CdTymHNu.d.ts +16 -0
  545. package/dist/provider-web-search-BJhXD5dH.js +2392 -0
  546. package/dist/provider-wizard-DMMYXjlW.js +152 -0
  547. package/dist/push-apns-BnWTdTEk.js +1038 -0
  548. package/dist/pw-ai-CtK_7Cy2.js +1866 -0
  549. package/dist/qr-cli-CA-BF0--.js +108 -0
  550. package/dist/qr-cli-D18HiUkh.js +369 -0
  551. package/dist/reactions-Df7XG8Uh.js +281 -0
  552. package/dist/read-only-account-inspect.discord.runtime-B-FP0mwb.js +111 -0
  553. package/dist/read-only-account-inspect.slack.runtime-DkWZ2ccW.js +111 -0
  554. package/dist/read-only-account-inspect.telegram.runtime-BnlTkn_e.js +111 -0
  555. package/dist/redact-snapshot-DVdstBvO.js +2661 -0
  556. package/dist/ref-contract-RPkB754Q.js +53 -0
  557. package/dist/register.agent-DVAxXQKW.js +434 -0
  558. package/dist/register.backup-CUuL5KUZ.js +624 -0
  559. package/dist/register.configure-bC0UEwfU.js +247 -0
  560. package/dist/register.maintenance-iIqvl_eT.js +569 -0
  561. package/dist/register.message-CEDd4z07.js +704 -0
  562. package/dist/register.onboard-Cejfnysy.js +187 -0
  563. package/dist/register.setup-DU7uHdYt.js +207 -0
  564. package/dist/register.status-health-sessions-BWphMXNR.js +493 -0
  565. package/dist/register.subclis-DnIweTEG.js +315 -0
  566. package/dist/register.subclis-gJX_Pbub.js +12 -0
  567. package/dist/registry-Dgwc-7eS.js +1183 -0
  568. package/dist/replies-D9PEZ8yn.js +110 -0
  569. package/dist/reply-history-lHgoC4l3.d.ts +1 -0
  570. package/dist/reply-payload-Bd2HuR4g.d.ts +46 -0
  571. package/dist/request-url-BcSJaiiu.d.ts +5 -0
  572. package/dist/resolve-BbsCHGLY.js +660 -0
  573. package/dist/resolve-channels-BtrGC95o.js +262 -0
  574. package/dist/resolve-channels-C1SthO1N.js +226 -0
  575. package/dist/resolve-users-CgSxHrU0.js +143 -0
  576. package/dist/routes-BZtqNrBf.js +7097 -0
  577. package/dist/rpc-D3KMxG4J.js +67 -0
  578. package/dist/run-command-C8b3dCZV.d.ts +16 -0
  579. package/dist/run-main-BlWJVotF.js +423 -0
  580. package/dist/runtime-RWGbO5Qy.d.ts +26 -0
  581. package/dist/runtime-discord-ops.runtime-DUXIYvQr.js +9073 -0
  582. package/dist/runtime-slack-ops.runtime-n1yFfyp1.js +4551 -0
  583. package/dist/runtime-telegram-ops.runtime-PZUWchjT.js +128 -0
  584. package/dist/runtime-whatsapp-login.runtime-xsuNyvGz.js +109 -0
  585. package/dist/runtime-whatsapp-outbound.runtime-5EfEyCsO.js +112 -0
  586. package/dist/sandbox-cli-Dw1nWNmQ.js +530 -0
  587. package/dist/search-manager-BJoRxOaf.js +15 -0
  588. package/dist/search-manager-DxkQvUrW.js +386 -0
  589. package/dist/secret-input-schema-Cp_La9qv.d.ts +19 -0
  590. package/dist/secrets-cli-BPyV2gSq.js +2065 -0
  591. package/dist/security-cli-EK4sSRfG.js +570 -0
  592. package/dist/send-B01Gvh9m.js +629 -0
  593. package/dist/send-B4L4wRJO.js +100 -0
  594. package/dist/send-BDcGrXt0.js +1025 -0
  595. package/dist/send-BRRtHxyR.js +283 -0
  596. package/dist/send-DU6dmMXW.js +631 -0
  597. package/dist/server-CWw5GFEg.js +106 -0
  598. package/dist/server-node-events-92cDVswC.js +501 -0
  599. package/dist/session-key-DbkfhOjM.d.ts +46 -0
  600. package/dist/sessions-B052uHA3.js +218 -0
  601. package/dist/sessions-Cef4dZNP.js +107 -0
  602. package/dist/setup-BlQPyDPy.js +387 -0
  603. package/dist/setup-DcSZ_pTn.d.ts +37 -0
  604. package/dist/setup-core-B9mdZYnU.js +166 -0
  605. package/dist/setup-core-Cj0sLkpP.js +47 -0
  606. package/dist/setup-core-CkZbebOv.js +143 -0
  607. package/dist/setup-core-MRNjnrJl.js +205 -0
  608. package/dist/setup-surface-3ZY0JtWE.js +490 -0
  609. package/dist/setup-wizard-helpers-Dwzb9Dcz.d.ts +203 -0
  610. package/dist/setup.finalize-B5ETm3Ui.js +517 -0
  611. package/dist/setup.gateway-config-C8hdtlbw.js +338 -0
  612. package/dist/setup.secret-input-BZSIeiqy.js +25 -0
  613. package/dist/shared--9_eQ_lc.js +75 -0
  614. package/dist/shared-CxkH3H0U.js +102 -0
  615. package/dist/shared-DTNL0hA9.js +298 -0
  616. package/dist/shared-HSP1OV-Q.js +96 -0
  617. package/dist/shared-UIjWb_3B.js +182 -0
  618. package/dist/signal-CTI6bSmB.js +109 -0
  619. package/dist/skills-4-r1mfJM.js +853 -0
  620. package/dist/skills-RNm54CBO.js +19 -0
  621. package/dist/skills-cli-te7dSs5p.js +291 -0
  622. package/dist/skills-install-Del-Ogv8.js +763 -0
  623. package/dist/skills-status-BZpoMXrR.js +169 -0
  624. package/dist/skills-status-Dq61Sz8U.js +20 -0
  625. package/dist/slack-oc-viUtl.js +109 -0
  626. package/dist/slash-commands.runtime-NdkD2LZV.js +123 -0
  627. package/dist/slash-dispatch.runtime-DQgeaF3J.js +136 -0
  628. package/dist/slash-skill-commands.runtime-DmOl2DnL.js +111 -0
  629. package/dist/src-0wtt7seR.js +1696 -0
  630. package/dist/status-5oR_gqv_.js +121 -0
  631. package/dist/status-BO8LY0hC.js +1599 -0
  632. package/dist/status-D_oHA9yO.js +126 -0
  633. package/dist/status-IrMacJRj.js +606 -0
  634. package/dist/status-Prdeg53E.js +43 -0
  635. package/dist/status-json-Da0hR-1Z.js +286 -0
  636. package/dist/status.link-channel-BgUJEZAz.js +138 -0
  637. package/dist/status.scan.deps.runtime-D9vHTxOW.js +121 -0
  638. package/dist/status.scan.runtime-D-EdD5CW.js +114 -0
  639. package/dist/status.summary--i6xduWH.js +592 -0
  640. package/dist/status.summary.runtime-BqMXjaBc.js +113 -0
  641. package/dist/subagent-orphan-recovery-DiRJcFQc.js +302 -0
  642. package/dist/subagent-registry-runtime-B66EYEYm.js +106 -0
  643. package/dist/synology-chat-BemXqdzG.js +297 -0
  644. package/dist/system-cli-CSuiia4-.js +92 -0
  645. package/dist/telegram/audit.d.ts +2 -0
  646. package/dist/telegram/audit.js +1 -1
  647. package/dist/telegram/token.d.ts +2 -0
  648. package/dist/telegram/token.js +26 -26
  649. package/dist/telegram-DLFcRv5a.js +109 -0
  650. package/dist/testing-DZrulv-n.d.ts +1755 -0
  651. package/dist/text-chunking-BaYBIUoR.d.ts +79 -0
  652. package/dist/text-chunking-C8kmbNfa.js +84 -0
  653. package/dist/thinking-D8aqmr3o.d.ts +13 -0
  654. package/dist/tlon-Bpr4f3yF.js +433 -0
  655. package/dist/tool-send-BHKm5ztm.d.ts +9 -0
  656. package/dist/tui-BY3QRgC1.js +3834 -0
  657. package/dist/tui-cli-CCfZOlV0.js +132 -0
  658. package/dist/types-CKx5nDZB.d.ts +45 -0
  659. package/dist/types-DBhDdMQd.d.ts +22670 -0
  660. package/dist/types.base-B_TkkSS8.d.ts +188 -0
  661. package/dist/types.secrets-Bojc4omL.js +92 -0
  662. package/dist/ui-1UpZZyI3.js +31 -0
  663. package/dist/update-BR4JvFpV.js +1036 -0
  664. package/dist/update-cli-BZv44lFq.js +1498 -0
  665. package/dist/update-offset-store-DGdBotIW.js +107 -0
  666. package/dist/update-runner-D34sooPe.js +1496 -0
  667. package/dist/vllm-defaults-BCGSJ7K0.d.ts +13 -0
  668. package/dist/wait-BU9vJv22.d.ts +4 -0
  669. package/dist/web-CXpU2D41.js +107 -0
  670. package/dist/web-shared-B4sL45ah.d.ts +45 -0
  671. package/dist/webhook-memory-guards-B7oLVseG.d.ts +43 -0
  672. package/dist/webhook-request-guards-CqIH7equ.d.ts +76 -0
  673. package/dist/webhook-targets-CAAGATtk.js +181 -0
  674. package/dist/webhook-targets-oQ0jd4r0.d.ts +106 -0
  675. package/dist/webhooks-cli-B46t2VT5.js +349 -0
  676. package/dist/whatsapp-Dniwd4Rv.js +109 -0
  677. package/dist/whatsapp-actions-fL46PsNs.js +162 -0
  678. package/dist/windows-spawn-DGeE98SH.d.ts +43 -0
  679. package/dist/workspace-dirs-d3Ms_ryk.js +2002 -0
  680. package/dist/zalo-Csulx0XK.d.ts +9 -0
  681. package/dist/zalo-gh0yAWmS.js +415 -0
  682. package/dist/zalouser-CuxRvztM.js +30911 -0
  683. package/dist/zod-schema.agent-runtime-B4MkB-_3.d.ts +10 -0
  684. package/dist/zod-schema.core-D5reNip6.js +541 -0
  685. package/dist/zod-schema.core-DN3RhEUG.d.ts +173 -0
  686. package/docs/SEC1.md +523 -0
  687. package/docs/SEC1_IMPLEMENTATION/CHANNELS_REPORT.md +173 -0
  688. package/docs/SEC1_IMPLEMENTATION/CORE_UTIL_REPORT.md +139 -0
  689. package/docs/SEC1_IMPLEMENTATION/DOCS_REPORT.md +134 -0
  690. package/docs/SEC1_IMPLEMENTATION/ENV_MAP_DRAFT.md +148 -0
  691. package/docs/SEC1_IMPLEMENTATION/INTEGRATION_REPORT.md +170 -0
  692. package/docs/SEC1_IMPLEMENTATION/PROVIDERS_REPORT.md +291 -0
  693. package/docs/SEC1_IMPLEMENTATION/QA_REPORT.md +249 -0
  694. package/docs/SEC1_IMPLEMENTATION/RECURSIVE_QA/wave1-channels.md +317 -0
  695. package/docs/SEC1_IMPLEMENTATION/RECURSIVE_QA/wave1-docs.md +212 -0
  696. package/docs/SEC1_IMPLEMENTATION/RECURSIVE_QA/wave1-security.md +368 -0
  697. package/docs/SEC1_IMPLEMENTATION/RECURSIVE_QA/wave2-critic-consolidated.md +195 -0
  698. package/docs/SEC1_IMPLEMENTATION/RECURSIVE_QA/wave3-fix-report.md +105 -0
  699. package/docs/SEC1_IMPLEMENTATION/STRATEGY.md +451 -0
  700. package/docs/SEC1_IMPLEMENTATION/TEST_REPORT.md +156 -0
  701. package/docs/pipeline-sdk/CLI_SPEC.md +609 -0
  702. package/docs/pipeline-sdk/PIPELINE_SDK_DESIGN.md +1372 -0
  703. package/extensions/kakao-talkchannel/MIGRATION_ARCH_ANALYSIS.md +455 -0
  704. package/extensions/kakao-talkchannel/MIGRATION_CODE_ANALYSIS.md +383 -0
  705. package/extensions/kakao-talkchannel/MIGRATION_STRATEGY.md +115 -0
  706. package/extensions/kakao-talkchannel/README.md +50 -0
  707. package/extensions/kakao-talkchannel/index.ts +20 -0
  708. package/extensions/kakao-talkchannel/moldclaw.plugin.json +98 -0
  709. package/extensions/kakao-talkchannel/package.json +12 -0
  710. package/extensions/kakao-talkchannel/src/adapters/config.ts +132 -0
  711. package/extensions/kakao-talkchannel/src/adapters/gateway.ts +974 -0
  712. package/extensions/kakao-talkchannel/src/adapters/outbound.ts +52 -0
  713. package/extensions/kakao-talkchannel/src/adapters/pairing.ts +35 -0
  714. package/extensions/kakao-talkchannel/src/adapters/security.ts +57 -0
  715. package/extensions/kakao-talkchannel/src/adapters/setup.ts +105 -0
  716. package/extensions/kakao-talkchannel/src/adapters/status.ts +117 -0
  717. package/extensions/kakao-talkchannel/src/channel.ts +58 -0
  718. package/extensions/kakao-talkchannel/src/commands/card.ts +413 -0
  719. package/extensions/kakao-talkchannel/src/config/schema.ts +129 -0
  720. package/extensions/kakao-talkchannel/src/kakao/callback.ts +133 -0
  721. package/extensions/kakao-talkchannel/src/kakao/limits.ts +129 -0
  722. package/extensions/kakao-talkchannel/src/kakao/payload.ts +138 -0
  723. package/extensions/kakao-talkchannel/src/kakao/response.ts +373 -0
  724. package/extensions/kakao-talkchannel/src/relay/client.ts +146 -0
  725. package/extensions/kakao-talkchannel/src/relay/session.ts +137 -0
  726. package/extensions/kakao-talkchannel/src/relay/sse.ts +258 -0
  727. package/extensions/kakao-talkchannel/src/relay/stream.ts +149 -0
  728. package/extensions/kakao-talkchannel/src/runtime.ts +21 -0
  729. package/extensions/kakao-talkchannel/src/types.ts +447 -0
  730. package/extensions/kakao-talkchannel/src/version.ts +3 -0
  731. package/extensions/kakao-talkchannel/tsconfig.json +19 -0
  732. package/package.json +23 -8
  733. package/skills/meshy/SKILL.md +69 -0
  734. package/skills/meshy/scripts/__pycache__/check_status.cpython-312.pyc +0 -0
  735. package/skills/meshy/scripts/__pycache__/image_to_3d.cpython-312.pyc +0 -0
  736. package/skills/meshy/scripts/__pycache__/text_to_3d.cpython-312.pyc +0 -0
  737. package/skills/meshy/scripts/check_status.py +147 -0
  738. package/skills/meshy/scripts/image_to_3d.py +229 -0
  739. package/skills/meshy/scripts/text_to_3d.py +214 -0
  740. package/skills/nano-banana-pro/scripts/generate_image.py +1 -1
  741. package/skills/openai-whisper-api/scripts/transcribe.sh +0 -0
  742. package/skills/tavily-search/SKILL.md +61 -0
  743. package/skills/tavily-search/scripts/__pycache__/search.cpython-312.pyc +0 -0
  744. package/skills/tavily-search/scripts/search.py +238 -0
  745. package/skills/video-frames/scripts/frame.sh +0 -0
  746. package/LICENSE +0 -21
  747. package/dist/accounts-UcSvD34O.js +0 -109
  748. package/dist/acp-cli-BPb8PgHP.js +0 -2088
  749. package/dist/actions.runtime-BL5QRooG.js +0 -114
  750. package/dist/actions.runtime-DSdfSo40.js +0 -128
  751. package/dist/agents-CHeX_5-H.js +0 -217
  752. package/dist/agents-DQRL9XKP.js +0 -853
  753. package/dist/allow-list-Boi79v-U.js +0 -81
  754. package/dist/allowlist-B2eBBeMF.js +0 -142
  755. package/dist/api-CFAtRSYL.js +0 -6953
  756. package/dist/api-D5JNJj8n.js +0 -112
  757. package/dist/audit-BM0GsdzV.js +0 -787
  758. package/dist/audit-BqRK9OSj.js +0 -54
  759. package/dist/audit-channel.collect.runtime-BPvDB8aq.js +0 -600
  760. package/dist/audit-channel.runtime-D3fzHiAo.js +0 -116
  761. package/dist/audit-extra.async-NveNIzX0.js +0 -813
  762. package/dist/audit-membership-runtime-mu470WFO.js +0 -157
  763. package/dist/audit.deep.runtime-RdxvW8Tj.js +0 -24
  764. package/dist/audit.nondeep.runtime-DDu8vA9Z.js +0 -831
  765. package/dist/audit.runtime-Y8C9W7s9.js +0 -113
  766. package/dist/auth-choice-C1CIxRsi.js +0 -268
  767. package/dist/auth-choice-CTvqWiDI.js +0 -117
  768. package/dist/auth-choice-Ddzko1B8.js +0 -502
  769. package/dist/auth-choice-options-BIAmAiCe.js +0 -123
  770. package/dist/auth-choice-prompt-B815kArz.js +0 -110
  771. package/dist/auth-choice-prompt-CGhTNCJx.js +0 -36
  772. package/dist/auth-choice.plugin-providers.runtime-AvAZ6S5W.js +0 -114
  773. package/dist/auth-profiles-BJcHzwPy.js +0 -127650
  774. package/dist/auth-profiles.runtime-CieFilK5.js +0 -111
  775. package/dist/bluebubbles-F8FGE9cH.js +0 -64
  776. package/dist/brave-BG5Yopn8.js +0 -24
  777. package/dist/browser-cli-Co7PJGZF.js +0 -1492
  778. package/dist/call-CoaQYq7c.js +0 -639
  779. package/dist/call-D3eu5Jjh.js +0 -37
  780. package/dist/channel-BftWD6yu.js +0 -1321
  781. package/dist/channel-Bub9U5Xg.js +0 -214
  782. package/dist/channel-C0oDs7TO.js +0 -4681
  783. package/dist/channel-C8CnEdkZ.js +0 -352
  784. package/dist/channel-CI-RC-xf.js +0 -497
  785. package/dist/channel-CY-hZCOJ.js +0 -397
  786. package/dist/channel-CbtGJB2x.js +0 -943
  787. package/dist/channel-CcfK3wP8.js +0 -803
  788. package/dist/channel-DBoDIeVj.js +0 -619
  789. package/dist/channel-DEq6Ecs-.js +0 -920
  790. package/dist/channel-DH4dhW1n.js +0 -226
  791. package/dist/channel-DQ_wdKg_.js +0 -575
  792. package/dist/channel-DT6qD1Ic.js +0 -207
  793. package/dist/channel-DZNAyxwr.js +0 -542
  794. package/dist/channel-DtakwAEe.js +0 -538
  795. package/dist/channel-DuYgH6p1.js +0 -562
  796. package/dist/channel-Hn-AN-d52.js +0 -316
  797. package/dist/channel-_R4hbD5h.js +0 -1598
  798. package/dist/channel-account-context-DXq8dlvI.js +0 -103
  799. package/dist/channel-kQmEVn3I.js +0 -306
  800. package/dist/channel-options-DHfxaklg.js +0 -50
  801. package/dist/channel-summary-DUpnoYhI.js +0 -106
  802. package/dist/channel-t-JxCWk6.js +0 -949
  803. package/dist/channel.runtime--GYriaXU.js +0 -213
  804. package/dist/channel.runtime-BJtn3GOH.js +0 -174
  805. package/dist/channel.runtime-BV7t_oNz.js +0 -166
  806. package/dist/channel.runtime-Bi8a3n9S.js +0 -865
  807. package/dist/channel.runtime-BjsYF0NN.js +0 -122
  808. package/dist/channel.runtime-BnI6YtmI.js +0 -413
  809. package/dist/channel.runtime-CQOftcCd.js +0 -194
  810. package/dist/channel.runtime-CuIAcPjZ.js +0 -4006
  811. package/dist/channel.runtime-DH1Q1G4k.js +0 -399
  812. package/dist/channel.runtime-DYYUPKxr.js +0 -236
  813. package/dist/channel.runtime-U5Gszsr5.js +0 -177
  814. package/dist/channel.setup-BQFHmgki.js +0 -9
  815. package/dist/channel.setup-BVoDwklu.js +0 -8
  816. package/dist/channel.setup-Bf73HsXr.js +0 -57
  817. package/dist/channel.setup-CblD4flM.js +0 -11
  818. package/dist/channel.setup-DgxlrPgz.js +0 -6
  819. package/dist/channel.setup-GLIAEVKL.js +0 -8
  820. package/dist/channel.setup-YTy5R1sz.js +0 -9
  821. package/dist/channels-CTL8iR9J.js +0 -404
  822. package/dist/channels-DBGvnjHY.js +0 -1113
  823. package/dist/channels-cli-BmVO5-sq.js +0 -286
  824. package/dist/channels-status-issues-kDtsWzA-.js +0 -16
  825. package/dist/clawbot-cli-DtcMJHqX.js +0 -113
  826. package/dist/cli-BNGECGVY.js +0 -149
  827. package/dist/command-registry-1SDrWgER.js +0 -13
  828. package/dist/command-registry-DNorYU4w.js +0 -212
  829. package/dist/command-secret-gateway-DqDZparO.js +0 -106
  830. package/dist/compact.runtime-C1ZN8UGb.js +0 -111
  831. package/dist/completion-cli-Q_Jt5Foc.js +0 -16
  832. package/dist/completion-cli-QkTXhuJh.js +0 -445
  833. package/dist/config-BbxrRaLf.js +0 -938
  834. package/dist/config-CkD8DJ7L.js +0 -44
  835. package/dist/config-cli-BoPrlYTp.js +0 -428
  836. package/dist/config-guard-CEhCvr_u.js +0 -117
  837. package/dist/config-schema-GQ6uWjXe.js +0 -31
  838. package/dist/config-validation-woE2_LpC.js +0 -262
  839. package/dist/config-value-Dh8m-CFf.js +0 -132
  840. package/dist/config-y4i5g7s4.js +0 -30
  841. package/dist/configure-DGRzwdFN.js +0 -1100
  842. package/dist/configure-S4AHE3k_.js +0 -238
  843. package/dist/control-ui-shared-kLBp4YlS.js +0 -29
  844. package/dist/credentials-D5uBf_C5.js +0 -265
  845. package/dist/cron-cli-lGupeVCW.js +0 -634
  846. package/dist/daemon-cli-Cs_edi0I.js +0 -339
  847. package/dist/daemon-install-DIFpP_qv.js +0 -175
  848. package/dist/deliver-DYa_DFZU.js +0 -106
  849. package/dist/deliver-runtime-DCW_o2Ot.js +0 -106
  850. package/dist/devices-cli-YsGOW2-w.js +0 -340
  851. package/dist/diagnostic-vMghIesG.js +0 -310
  852. package/dist/directory-cli-DtjMQjU5.js +0 -306
  853. package/dist/directory.static-DBZGvsdF.js +0 -44
  854. package/dist/discord-DYCu19HT.js +0 -109
  855. package/dist/discovery-DZYAoDF_.js +0 -48
  856. package/dist/dns-cli-DqW4pNgW.js +0 -216
  857. package/dist/docs-cli-Bu9TBlDU.js +0 -173
  858. package/dist/doctor-completion-B5hcQD5c.js +0 -90
  859. package/dist/doctor-config-flow-BBB2ZKfT.js +0 -107
  860. package/dist/doctor-config-flow-DDBYUS9f.js +0 -2437
  861. package/dist/enable-Tmsp8QuB.js +0 -24
  862. package/dist/env-overrides-BHxqjYZG.js +0 -434
  863. package/dist/env-overrides.runtime-Cz98bf-l.js +0 -17
  864. package/dist/exec-approvals-cli-wO5cYfMa.js +0 -419
  865. package/dist/gateway-cli-CFvDGhB9.js +0 -26429
  866. package/dist/gateway-install-token-CskJfo_N.js +0 -163
  867. package/dist/gateway-rpc-srYfBID9.js +0 -26
  868. package/dist/gateway-runtime-C76hUmUV.js +0 -69
  869. package/dist/googlechat-Cha5utST.js +0 -307
  870. package/dist/health-DDQYYsJy.js +0 -108
  871. package/dist/health-DXZykGaX.js +0 -570
  872. package/dist/hooks-cli-DfkurPYP.js +0 -995
  873. package/dist/imessage-B26k39pl.js +0 -110
  874. package/dist/imessage-Bp1_6cws.js +0 -31
  875. package/dist/inbound-reply-dispatch-DoIJLztA.js +0 -71
  876. package/dist/install-target-BjOuS4I8.js +0 -574
  877. package/dist/installs-Cz4k0W1Y.js +0 -532
  878. package/dist/io-B0OKifLZ.js +0 -28
  879. package/dist/io-DcoxdH6t.js +0 -9570
  880. package/dist/ipv4-CTQQ4_IW.js +0 -82
  881. package/dist/irc-B8vBDigm.js +0 -672
  882. package/dist/library-VCM_cQY4.js +0 -107
  883. package/dist/lifecycle-core-Ctz36PdQ.js +0 -382
  884. package/dist/line-B_uTLrdI.js +0 -530
  885. package/dist/llm-slug-generator-YWg0g2pj.js +0 -67
  886. package/dist/logging-S-5LPdfQ.js +0 -13
  887. package/dist/logging-ueBMCGMR.js +0 -29
  888. package/dist/login-qr-pcACm2Ng.js +0 -107
  889. package/dist/login-qr-pv-kxMfF.js +0 -233
  890. package/dist/logs-cli-RgADgSMO.js +0 -254
  891. package/dist/manager-runtime-BhTkoKmb.js +0 -106
  892. package/dist/manager.runtime-BjHzikoK.js +0 -710
  893. package/dist/matrix-C4EEu2Qp.js +0 -1490
  894. package/dist/matrix-Dfzcc5nV.js +0 -1269
  895. package/dist/mcp-cli-CJmOm9Oj.js +0 -86
  896. package/dist/media-understanding.runtime-DCETFCw_.js +0 -111
  897. package/dist/memory-cli-DFqd6tYx.js +0 -106
  898. package/dist/method-scopes-D-Q9dvbj.js +0 -2586
  899. package/dist/model-picker-Z-CUcuMr.js +0 -390
  900. package/dist/model-picker-v5mUsZ4J.js +0 -107
  901. package/dist/model-picker.runtime-A_z0dHfS.js +0 -120
  902. package/dist/model-suppression.runtime-QVWVJRr-.js +0 -111
  903. package/dist/models-Bbj0xV4F.js +0 -2514
  904. package/dist/models-D-OIjZqU.js +0 -113
  905. package/dist/models-cli-Bpn-5i4h.js +0 -304
  906. package/dist/models-config-Cwa5cJbC.js +0 -106
  907. package/dist/monitor-BchfCAaU.js +0 -6823
  908. package/dist/monitor-BydV44SP.js +0 -3076
  909. package/dist/monitor-CT8axwfm.js +0 -767
  910. package/dist/monitor-CZGWNOvn.js +0 -777
  911. package/dist/monitor-DN62r69g.js +0 -3468
  912. package/dist/monitor-DZ0fzJku.js +0 -110
  913. package/dist/monitor-DvNjzWFu.js +0 -108
  914. package/dist/monitor-shared-B-DBSlkQ.js +0 -444
  915. package/dist/msteams-Bf-wk2Rp.js +0 -852
  916. package/dist/node-cli-kH16TQI7.js +0 -2498
  917. package/dist/node-resolve-DfOpQmxm.js +0 -835
  918. package/dist/nodes-cli-CkAMXW5u.js +0 -1375
  919. package/dist/nostr-B8UGHclZ.js +0 -8744
  920. package/dist/npm-resolution-DmjlifII.js +0 -60
  921. package/dist/onboard-C883nfyw.js +0 -589
  922. package/dist/onboard-channels-Dc-BxN7p.js +0 -200
  923. package/dist/onboard-channels-j5EENtum.js +0 -1241
  924. package/dist/onboard-custom-0atne0C5.js +0 -571
  925. package/dist/onboard-custom-CWMqwjJx.js +0 -109
  926. package/dist/onboard-helpers-D3wWfH8F.js +0 -335
  927. package/dist/onboard-helpers-DZmRCe8l.js +0 -108
  928. package/dist/onboard-remote-Cn6kW-p0.js +0 -112
  929. package/dist/onboard-remote-Cx4w5VAk.js +0 -181
  930. package/dist/onboard-search-Ck9HRh2M.js +0 -297
  931. package/dist/onboard-skills-BtqrGioT.js +0 -133
  932. package/dist/onboard-skills-Dnw19Os8.js +0 -112
  933. package/dist/outbound-media-C5Nv4o18.js +0 -11
  934. package/dist/pairing-cli-Cwy9QZ_4.js +0 -212
  935. package/dist/perplexity-Brhpb45X.js +0 -24
  936. package/dist/pi-model-discovery-runtime-DIOdo6D8.js +0 -106
  937. package/dist/pi-tools.before-tool-call.runtime-CFM4gsDF.js +0 -380
  938. package/dist/plugin-install-BOV00hia.js +0 -112
  939. package/dist/plugin-install-Bak8fUBv.js +0 -184
  940. package/dist/plugin-install-plan-bKkEefRf.js +0 -49
  941. package/dist/plugin-registry-DxAXQUlZ.js +0 -108
  942. package/dist/plugin-registry-n0p3phem.js +0 -49
  943. package/dist/plugins-Ca3RK8Fi.js +0 -106
  944. package/dist/plugins-cli-BnC51H2R.js +0 -912
  945. package/dist/policy-BJv97w9e.js +0 -143
  946. package/dist/preflight-audio.runtime-BrFcf-6_.js +0 -111
  947. package/dist/probe-063xvvZc.js +0 -19
  948. package/dist/probe-BJEb2wGv.js +0 -1793
  949. package/dist/probe-CJQlxgsl.js +0 -47
  950. package/dist/probe-Caa2HznF.js +0 -6328
  951. package/dist/probe-CfL4tnJ6.js +0 -129
  952. package/dist/probe-auth-DN2Ec83-.js +0 -38
  953. package/dist/probe-auth-D_UKzu4m.js +0 -48
  954. package/dist/program-BOMdC7MC.js +0 -247
  955. package/dist/prompt-select-styled-DDnCfM3j.js +0 -2673
  956. package/dist/provider-api-key-auth.runtime-DUns3fwX.js +0 -116
  957. package/dist/provider-auth-choice-B_j1ctT2.js +0 -126
  958. package/dist/provider-auth-choice-preference-BaOBZ_Xn.js +0 -189
  959. package/dist/provider-auth-choice.runtime-DOako_zV.js +0 -118
  960. package/dist/provider-auth-guidance-CrjxnoNZ.js +0 -34
  961. package/dist/provider-runtime.runtime-BkOkgmTw.js +0 -106
  962. package/dist/provider-self-hosted-setup-BFDU6dRa.js +0 -182
  963. package/dist/provider-usage-CaDE0mqq.js +0 -106
  964. package/dist/provider-web-search-BR7etTjJ.js +0 -2392
  965. package/dist/provider-wizard-DCPdKUvb.js +0 -152
  966. package/dist/push-apns-B_OZjm4v.js +0 -1038
  967. package/dist/pw-ai-dG60P0hQ.js +0 -1866
  968. package/dist/qr-cli-DWfiw79I.js +0 -369
  969. package/dist/qr-cli-DwuKtyZQ.js +0 -108
  970. package/dist/reactions-CIGAPBn8.js +0 -281
  971. package/dist/read-only-account-inspect.discord.runtime-D54mnq8l.js +0 -111
  972. package/dist/read-only-account-inspect.slack.runtime-Bxs9ObMC.js +0 -111
  973. package/dist/read-only-account-inspect.telegram.runtime-UoVuf_Yo.js +0 -111
  974. package/dist/redact-snapshot-DZ3Vq-SC.js +0 -2657
  975. package/dist/ref-contract-D96lSYLs.js +0 -53
  976. package/dist/register.agent-2KmeahEL.js +0 -434
  977. package/dist/register.backup-ECBnWVR7.js +0 -624
  978. package/dist/register.configure-Doz1daCp.js +0 -247
  979. package/dist/register.maintenance-C33cV-WM.js +0 -569
  980. package/dist/register.message-CnL0NiF6.js +0 -704
  981. package/dist/register.onboard-BrYGZeQA.js +0 -187
  982. package/dist/register.setup-Bx6gEg6X.js +0 -207
  983. package/dist/register.status-health-sessions-FLb0CUOO.js +0 -493
  984. package/dist/register.subclis-BuqgaeIf.js +0 -12
  985. package/dist/register.subclis-DwdgfdnT.js +0 -315
  986. package/dist/registry-xhgvU89y.js +0 -1107
  987. package/dist/replies-hB2aipLu.js +0 -110
  988. package/dist/resolve-3ErMOltL.js +0 -660
  989. package/dist/resolve-channels-BV8GXuPe.js +0 -226
  990. package/dist/resolve-channels-CTY_XRIP.js +0 -262
  991. package/dist/resolve-users-DQ4Ne4Zc.js +0 -143
  992. package/dist/routes-BNDsNO_e.js +0 -7097
  993. package/dist/rpc-BLGTBWXq.js +0 -67
  994. package/dist/run-main-COAE4GlI.js +0 -423
  995. package/dist/runtime-discord-ops.runtime-Dxg-nlgd.js +0 -9073
  996. package/dist/runtime-slack-ops.runtime-Di474LJr.js +0 -4551
  997. package/dist/runtime-telegram-ops.runtime-Da8vgf3O.js +0 -128
  998. package/dist/runtime-whatsapp-login.runtime-DcouP4iF.js +0 -109
  999. package/dist/runtime-whatsapp-outbound.runtime-CYamaEJX.js +0 -112
  1000. package/dist/sandbox-cli-U5ZTxhxL.js +0 -530
  1001. package/dist/search-manager-CfizyEMk.js +0 -386
  1002. package/dist/search-manager-DaF2QP4s.js +0 -15
  1003. package/dist/secrets-cli-C0gytFip.js +0 -2065
  1004. package/dist/security-cli-C74EuLUO.js +0 -570
  1005. package/dist/send-BTLVBf_E.js +0 -631
  1006. package/dist/send-BlWWCEZE.js +0 -1025
  1007. package/dist/send-CfypD1B_.js +0 -100
  1008. package/dist/send-Cm9v3uhF.js +0 -283
  1009. package/dist/send-g2odQuYI.js +0 -629
  1010. package/dist/server-C8b5QJ2s.js +0 -106
  1011. package/dist/server-node-events-xqQe5xiu.js +0 -501
  1012. package/dist/sessions-CSSzvgPQ.js +0 -107
  1013. package/dist/sessions-z0GIvdKa.js +0 -218
  1014. package/dist/setup-D9XTmlF8.js +0 -387
  1015. package/dist/setup-core-BDrLOwYO.js +0 -143
  1016. package/dist/setup-core-CM7cY7_i.js +0 -166
  1017. package/dist/setup-core-CnmgANY-.js +0 -205
  1018. package/dist/setup-core-DgcjCKmG.js +0 -47
  1019. package/dist/setup-surface-DzRrVKYj.js +0 -490
  1020. package/dist/setup.finalize-UaPu_adv.js +0 -517
  1021. package/dist/setup.gateway-config-Djc1ceEh.js +0 -338
  1022. package/dist/setup.secret-input-BkczghbR.js +0 -25
  1023. package/dist/shared-BHizGoNk.js +0 -298
  1024. package/dist/shared-CUfYhQkP.js +0 -96
  1025. package/dist/shared-DYYqr9EC.js +0 -75
  1026. package/dist/shared-DthOxMRQ.js +0 -182
  1027. package/dist/shared-On_A5_hW.js +0 -102
  1028. package/dist/signal-D6px9PGZ.js +0 -109
  1029. package/dist/skills-B4h1k-SP.js +0 -853
  1030. package/dist/skills-Bto10BGB.js +0 -19
  1031. package/dist/skills-cli-CXGR3Y5j.js +0 -291
  1032. package/dist/skills-install-B1AlkK8C.js +0 -763
  1033. package/dist/skills-status-BsmJ_iSg.js +0 -20
  1034. package/dist/skills-status-DGdxY3OI.js +0 -169
  1035. package/dist/slack-B7vWFmxP.js +0 -109
  1036. package/dist/slash-commands.runtime-DXdAT84n.js +0 -123
  1037. package/dist/slash-dispatch.runtime-CNf2-9Aj.js +0 -136
  1038. package/dist/slash-skill-commands.runtime-CBjffHRX.js +0 -111
  1039. package/dist/src-Cp7P7T08.js +0 -1696
  1040. package/dist/status-158fWh4A.js +0 -43
  1041. package/dist/status-BJIVLJnb.js +0 -1599
  1042. package/dist/status-BQiBI6N9.js +0 -126
  1043. package/dist/status-CZipXGUu.js +0 -121
  1044. package/dist/status-ZZIVFLI-.js +0 -606
  1045. package/dist/status-json-BNUy5Mem.js +0 -286
  1046. package/dist/status.link-channel-B694y1Xu.js +0 -138
  1047. package/dist/status.scan.deps.runtime-BcoKEzQD.js +0 -121
  1048. package/dist/status.scan.runtime-CqScDt-p.js +0 -114
  1049. package/dist/status.summary-AMek7qvI.js +0 -592
  1050. package/dist/status.summary.runtime-XgkcQ_kr.js +0 -113
  1051. package/dist/subagent-orphan-recovery-CrCYTmFC.js +0 -302
  1052. package/dist/subagent-registry-runtime-Cg-YvLx3.js +0 -106
  1053. package/dist/synology-chat-0G85jIqQ.js +0 -297
  1054. package/dist/system-cli-kZtSxKNm.js +0 -92
  1055. package/dist/telegram-DV0Wy89w.js +0 -109
  1056. package/dist/text-chunking-C2J2Oeul.js +0 -84
  1057. package/dist/tlon-DmK1NUVP.js +0 -433
  1058. package/dist/tui-D3bNPLG7.js +0 -3834
  1059. package/dist/tui-cli-DtMp9k_s.js +0 -132
  1060. package/dist/types.secrets-DuSPmmWB.js +0 -80
  1061. package/dist/ui-CeGztSEL.js +0 -31
  1062. package/dist/update-De7VudzP.js +0 -1036
  1063. package/dist/update-cli-BH8Pb-So.js +0 -1498
  1064. package/dist/update-offset-store-syELkdEW.js +0 -107
  1065. package/dist/update-runner-Cq-Q40T9.js +0 -1496
  1066. package/dist/web-CjMtvfSq.js +0 -107
  1067. package/dist/webhook-targets-_jTR0Bb_.js +0 -181
  1068. package/dist/webhooks-cli-DQ6u2Qau.js +0 -349
  1069. package/dist/whatsapp-CyLk16SZ.js +0 -109
  1070. package/dist/whatsapp-actions-Dzr2Wzqw.js +0 -162
  1071. package/dist/workspace-dirs-L1_QQ9mB.js +0 -2002
  1072. package/dist/zalo-CrehfXvK.js +0 -415
  1073. package/dist/zalouser-D1QD-O-I.js +0 -30911
  1074. package/dist/zod-schema.core-CWxzqcUs.js +0 -541
@@ -0,0 +1,4006 @@
1
+ import { t as __commonJSMin } from "./chunk-DORXReHP.js";
2
+ import "./redact-fatrROh9.js";
3
+ import "./errors-DOJWZqNo.js";
4
+ import "./unhandled-rejections-CTvNvnT0.js";
5
+ import "./logger-BFfIIIKH.js";
6
+ import "./paths-D6AgsMTU.js";
7
+ import "./tmp-moldclaw-dir-DWF-d8qD.js";
8
+ import "./theme-BSXzMzAA.js";
9
+ import "./globals-DESrFYmC.js";
10
+ import "./subsystem-S4LNMNHd.js";
11
+ import "./ansi-BPhP6LBZ.js";
12
+ import "./boolean-D8Ha5nYV.js";
13
+ import "./env-Dgex_t9p.js";
14
+ import "./warning-filter-gJuwHM7C.js";
15
+ import "./utils-rjVNXUns.js";
16
+ import "./links-C5I443Xb.js";
17
+ import "./setup-binary-Fw3cCSWL.js";
18
+ import { WS as createDedupeCache } from "./auth-profiles-9zZdaXJK.js";
19
+ import "./model-selection-DfA4esOK.js";
20
+ import "./agent-scope-DA7O8MVG.js";
21
+ import "./boundary-file-read-Y1cMjPlu.js";
22
+ import "./logger-wrbK9-ju.js";
23
+ import "./exec-CoBTyh8B.js";
24
+ import "./workspace-CxNKYS0V.js";
25
+ import "./io-C6XifaT4.js";
26
+ import "./host-env-security-xy11yVnm.js";
27
+ import "./safe-text-BcUvBreN.js";
28
+ import "./version-rW_3ob2o.js";
29
+ import "./env-substitution-C9xZMTDL.js";
30
+ import "./config-state-D1JkXt39.js";
31
+ import "./network-mode-CE-ihBf6.js";
32
+ import "./registry-DcDGl2X7.js";
33
+ import "./manifest-registry-_0xclaVY.js";
34
+ import "./ip-w605xvSx.js";
35
+ import "./zod-schema.core-D5reNip6.js";
36
+ import "./config-B2W1zTP1.js";
37
+ import "./audit-fs-SjcfoPO7.js";
38
+ import "./resolve-BbsCHGLY.js";
39
+ import { J as fetchWithSsrFGuard } from "./provider-web-search-BJhXD5dH.js";
40
+ import "./text-runtime-CgEQ9Y9_.js";
41
+ import "./workspace-dirs-d3Ms_ryk.js";
42
+ import "./config-CMhKplgO.js";
43
+ import "./tailnet-KyAU6tj_.js";
44
+ import "./net-B_Iq_SVP.js";
45
+ import "./credentials-yYt6VWCq.js";
46
+ import "./routes-BZtqNrBf.js";
47
+ import "./frontmatter-BTDAgsA3.js";
48
+ import "./env-overrides-DYVIkuvN.js";
49
+ import "./path-alias-guards-B3ZKrId1.js";
50
+ import "./skills-4-r1mfJM.js";
51
+ import "./ports-BVwQuCIR.js";
52
+ import "./ports-lsof-DiY6GaAf.js";
53
+ import "./ssh-tunnel-BaHTFPzH.js";
54
+ import "./image-ops-Uw4rEShL.js";
55
+ import "./fs-safe-Da4H0IOU.js";
56
+ import "./mime-_IkgFMS2.js";
57
+ import "./server-middleware-BPq4bu3A.js";
58
+ import "./message-channel-CKeDAoOT.js";
59
+ import "./resolve-route-IkBfMjBz.js";
60
+ import "./internal-hooks-0x1JiQ5f.js";
61
+ import "./lazy-runtime-DdzFA4b9.js";
62
+ import "./config-schema-pPBCF4hz.js";
63
+ import "./method-scopes-Du8ODGFW.js";
64
+ import "./session-cost-usage-B-57mlS8.js";
65
+ import "./paths-CDWV-9nX.js";
66
+ import "./routing-3o2D0ix4.js";
67
+ import "./send-BRRtHxyR.js";
68
+ import "./node-resolve-CupmrA0Y.js";
69
+ import "./provider-stream-gVymYPmd.js";
70
+ import "./identity-file-DM4N5_7H.js";
71
+ import "./provider-models-BA3hqqPq.js";
72
+ import "./secret-file-Bjh19aoH.js";
73
+ import "./logging-BdFqMomc.js";
74
+ import "./runtime-env-CT-voxYE.js";
75
+ import "./registry-Dgwc-7eS.js";
76
+ import "./provider-onboard-CBC3kdk_.js";
77
+ import "./model-definitions-DwehIMlw.js";
78
+ import "./diagnostic-CkiYEGqt.js";
79
+ import "./message-hook-mappers-DORrSLHM.js";
80
+ import "./json-store-DlpyvQXN.js";
81
+ import "./call-DYFR7oGy.js";
82
+ import "./multimodal-BWF8MRkz.js";
83
+ import "./memory-search-BBG2BKIh.js";
84
+ import "./query-expansion-8R79qExs.js";
85
+ import "./search-manager-DxkQvUrW.js";
86
+ import "./core-EKuk2FxR.js";
87
+ import "./issue-format-i6sEuV4a.js";
88
+ import "./logging-BhqLWxTD.js";
89
+ import "./note-z78_JyNp.js";
90
+ import "./state-paths-C7dX__ql.js";
91
+ import "./config-value-Dl3XEpA6.js";
92
+ import "./command-secret-targets-CO_lZ_ZZ.js";
93
+ import "./brave-CljenznH.js";
94
+ import "./provider-usage-DzuzbNBv.js";
95
+ import "./perplexity-Bw1u3CAF.js";
96
+ import "./restart-stale-pids-CN9ElYwR.js";
97
+ import "./delivery-queue-DLjFP-0C.js";
98
+ import "./pairing-token-ANLRyJSu.js";
99
+ import "./accounts-BCaV8MsT.js";
100
+ import "./process-runtime-CicRKAFe.js";
101
+ import "./audit-hdKa3D-u.js";
102
+ import "./cli-runtime-DtIDS2w7.js";
103
+ import "./cli-utils-FHeUZLsT.js";
104
+ import "./help-format-1yV2Xzq7.js";
105
+ import "./progress-BQSTKUhd.js";
106
+ import "./gateway-runtime-D9FRZqKP.js";
107
+ import { t as createLoggerBackedRuntime } from "./runtime-CE5bcF01.js";
108
+ import { c as normalizeShip, d as resolveTlonOutboundTarget, i as validateUrbitBaseUrl, l as parseChannelNest, o as resolveTlonAccount, s as formatTargetHint, t as tlonSetupWizard, u as parseTlonTarget } from "./tlon-Bpr4f3yF.js";
109
+ import { t as getTlonRuntime } from "./runtime-BJAuhWGc.js";
110
+ import { createWriteStream } from "node:fs";
111
+ import * as path$1 from "node:path";
112
+ import { homedir } from "node:os";
113
+ import { mkdir } from "node:fs/promises";
114
+ import crypto, { randomUUID } from "node:crypto";
115
+ import { pipeline } from "node:stream/promises";
116
+ import { Readable } from "node:stream";
117
+ import { configureClient, uploadFile } from "@tloncorp/api";
118
+ //#region extensions/tlon/src/settings.ts
119
+ const SETTINGS_DESK = "moltbot";
120
+ const SETTINGS_BUCKET = "tlon";
121
+ /**
122
+ * Parse channelRules - handles both JSON string and object formats.
123
+ * Settings-store doesn't support nested objects, so we store as JSON string.
124
+ */
125
+ function parseChannelRules(value) {
126
+ if (!value) return;
127
+ if (typeof value === "string") try {
128
+ const parsed = JSON.parse(value);
129
+ if (isChannelRulesObject(parsed)) return parsed;
130
+ } catch {
131
+ return;
132
+ }
133
+ if (isChannelRulesObject(value)) return value;
134
+ }
135
+ /**
136
+ * Parse settings from the raw Urbit settings-store response.
137
+ * The response shape is: { [bucket]: { [key]: value } }
138
+ */
139
+ function parseSettingsResponse(raw) {
140
+ if (!raw || typeof raw !== "object") return {};
141
+ const bucket = raw[SETTINGS_BUCKET];
142
+ if (!bucket || typeof bucket !== "object") return {};
143
+ const settings = bucket;
144
+ return {
145
+ groupChannels: Array.isArray(settings.groupChannels) ? settings.groupChannels.filter((x) => typeof x === "string") : void 0,
146
+ dmAllowlist: Array.isArray(settings.dmAllowlist) ? settings.dmAllowlist.filter((x) => typeof x === "string") : void 0,
147
+ autoDiscover: typeof settings.autoDiscover === "boolean" ? settings.autoDiscover : void 0,
148
+ showModelSig: typeof settings.showModelSig === "boolean" ? settings.showModelSig : void 0,
149
+ autoAcceptDmInvites: typeof settings.autoAcceptDmInvites === "boolean" ? settings.autoAcceptDmInvites : void 0,
150
+ autoAcceptGroupInvites: typeof settings.autoAcceptGroupInvites === "boolean" ? settings.autoAcceptGroupInvites : void 0,
151
+ groupInviteAllowlist: Array.isArray(settings.groupInviteAllowlist) ? settings.groupInviteAllowlist.filter((x) => typeof x === "string") : void 0,
152
+ channelRules: parseChannelRules(settings.channelRules),
153
+ defaultAuthorizedShips: Array.isArray(settings.defaultAuthorizedShips) ? settings.defaultAuthorizedShips.filter((x) => typeof x === "string") : void 0,
154
+ ownerShip: typeof settings.ownerShip === "string" ? settings.ownerShip : void 0,
155
+ pendingApprovals: parsePendingApprovals(settings.pendingApprovals)
156
+ };
157
+ }
158
+ function isChannelRulesObject(val) {
159
+ if (!val || typeof val !== "object" || Array.isArray(val)) return false;
160
+ for (const [, rule] of Object.entries(val)) if (!rule || typeof rule !== "object") return false;
161
+ return true;
162
+ }
163
+ /**
164
+ * Parse pendingApprovals - handles both JSON string and array formats.
165
+ * Settings-store stores complex objects as JSON strings.
166
+ */
167
+ function parsePendingApprovals(value) {
168
+ if (!value) return;
169
+ let parsed = value;
170
+ if (typeof value === "string") try {
171
+ parsed = JSON.parse(value);
172
+ } catch {
173
+ return;
174
+ }
175
+ if (!Array.isArray(parsed)) return;
176
+ return parsed.filter((item) => {
177
+ if (!item || typeof item !== "object") return false;
178
+ const obj = item;
179
+ return typeof obj.id === "string" && (obj.type === "dm" || obj.type === "channel" || obj.type === "group") && typeof obj.requestingShip === "string" && typeof obj.timestamp === "number";
180
+ });
181
+ }
182
+ /**
183
+ * Parse a single settings entry update event.
184
+ */
185
+ function parseSettingsEvent(event) {
186
+ if (!event || typeof event !== "object") return null;
187
+ const evt = event;
188
+ if (evt["put-entry"]) {
189
+ const put = evt["put-entry"];
190
+ if (put.desk !== SETTINGS_DESK || put["bucket-key"] !== SETTINGS_BUCKET) return null;
191
+ return {
192
+ key: String(put["entry-key"] ?? ""),
193
+ value: put.value
194
+ };
195
+ }
196
+ if (evt["del-entry"]) {
197
+ const del = evt["del-entry"];
198
+ if (del.desk !== SETTINGS_DESK || del["bucket-key"] !== SETTINGS_BUCKET) return null;
199
+ return {
200
+ key: String(del["entry-key"] ?? ""),
201
+ value: void 0
202
+ };
203
+ }
204
+ return null;
205
+ }
206
+ /**
207
+ * Apply a single settings update to the current state.
208
+ */
209
+ function applySettingsUpdate(current, key, value) {
210
+ const next = { ...current };
211
+ switch (key) {
212
+ case "groupChannels":
213
+ next.groupChannels = Array.isArray(value) ? value.filter((x) => typeof x === "string") : void 0;
214
+ break;
215
+ case "dmAllowlist":
216
+ next.dmAllowlist = Array.isArray(value) ? value.filter((x) => typeof x === "string") : void 0;
217
+ break;
218
+ case "autoDiscover":
219
+ next.autoDiscover = typeof value === "boolean" ? value : void 0;
220
+ break;
221
+ case "showModelSig":
222
+ next.showModelSig = typeof value === "boolean" ? value : void 0;
223
+ break;
224
+ case "autoAcceptDmInvites":
225
+ next.autoAcceptDmInvites = typeof value === "boolean" ? value : void 0;
226
+ break;
227
+ case "autoAcceptGroupInvites":
228
+ next.autoAcceptGroupInvites = typeof value === "boolean" ? value : void 0;
229
+ break;
230
+ case "groupInviteAllowlist":
231
+ next.groupInviteAllowlist = Array.isArray(value) ? value.filter((x) => typeof x === "string") : void 0;
232
+ break;
233
+ case "channelRules":
234
+ next.channelRules = parseChannelRules(value);
235
+ break;
236
+ case "defaultAuthorizedShips":
237
+ next.defaultAuthorizedShips = Array.isArray(value) ? value.filter((x) => typeof x === "string") : void 0;
238
+ break;
239
+ case "ownerShip":
240
+ next.ownerShip = typeof value === "string" ? value : void 0;
241
+ break;
242
+ case "pendingApprovals":
243
+ next.pendingApprovals = parsePendingApprovals(value);
244
+ break;
245
+ }
246
+ return next;
247
+ }
248
+ /**
249
+ * Create a settings store subscription manager.
250
+ *
251
+ * Usage:
252
+ * const settings = createSettingsManager(api, logger);
253
+ * await settings.load();
254
+ * settings.subscribe((newSettings) => { ... });
255
+ */
256
+ function createSettingsManager(api, logger) {
257
+ let state = {
258
+ current: {},
259
+ loaded: false
260
+ };
261
+ const listeners = /* @__PURE__ */ new Set();
262
+ const notify = () => {
263
+ for (const listener of listeners) try {
264
+ listener(state.current);
265
+ } catch (err) {
266
+ logger?.error?.(`[settings] Listener error: ${String(err)}`);
267
+ }
268
+ };
269
+ return {
270
+ get current() {
271
+ return state.current;
272
+ },
273
+ get loaded() {
274
+ return state.loaded;
275
+ },
276
+ async load() {
277
+ try {
278
+ const deskData = (await api.scry("/settings/all.json"))?.all?.[SETTINGS_DESK];
279
+ state.current = parseSettingsResponse(deskData ?? {});
280
+ state.loaded = true;
281
+ logger?.log?.(`[settings] Loaded: ${JSON.stringify(state.current)}`);
282
+ return state.current;
283
+ } catch (err) {
284
+ logger?.log?.(`[settings] No settings found (using defaults): ${String(err)}`);
285
+ state.current = {};
286
+ state.loaded = true;
287
+ return state.current;
288
+ }
289
+ },
290
+ async startSubscription() {
291
+ await api.subscribe({
292
+ app: "settings",
293
+ path: "/desk/" + SETTINGS_DESK,
294
+ event: (event) => {
295
+ const update = parseSettingsEvent(event);
296
+ if (!update) return;
297
+ logger?.log?.(`[settings] Update: ${update.key} = ${JSON.stringify(update.value)}`);
298
+ state.current = applySettingsUpdate(state.current, update.key, update.value);
299
+ notify();
300
+ },
301
+ err: (error) => {
302
+ logger?.error?.(`[settings] Subscription error: ${String(error)}`);
303
+ },
304
+ quit: () => {
305
+ logger?.log?.("[settings] Subscription ended");
306
+ }
307
+ });
308
+ logger?.log?.("[settings] Subscribed to settings updates");
309
+ },
310
+ onChange(listener) {
311
+ listeners.add(listener);
312
+ return () => listeners.delete(listener);
313
+ }
314
+ };
315
+ }
316
+ //#endregion
317
+ //#region extensions/tlon/src/urbit/errors.ts
318
+ var UrbitError = class extends Error {
319
+ constructor(code, message, options) {
320
+ super(message, options);
321
+ this.name = "UrbitError";
322
+ this.code = code;
323
+ }
324
+ };
325
+ var UrbitUrlError = class extends UrbitError {
326
+ constructor(message, options) {
327
+ super("invalid_url", message, options);
328
+ this.name = "UrbitUrlError";
329
+ }
330
+ };
331
+ var UrbitHttpError = class extends UrbitError {
332
+ constructor(params) {
333
+ const suffix = params.bodyText ? ` - ${params.bodyText}` : "";
334
+ super("http_error", `${params.operation} failed: ${params.status}${suffix}`, { cause: params.cause });
335
+ this.name = "UrbitHttpError";
336
+ this.status = params.status;
337
+ this.operation = params.operation;
338
+ this.bodyText = params.bodyText;
339
+ }
340
+ };
341
+ var UrbitAuthError = class extends UrbitError {
342
+ constructor(code, message, options) {
343
+ super(code, message, options);
344
+ this.name = "UrbitAuthError";
345
+ }
346
+ };
347
+ //#endregion
348
+ //#region extensions/tlon/src/urbit/fetch.ts
349
+ async function urbitFetch(params) {
350
+ const validated = validateUrbitBaseUrl(params.baseUrl);
351
+ if (!validated.ok) throw new UrbitUrlError(validated.error);
352
+ return await fetchWithSsrFGuard({
353
+ url: new URL(params.path, validated.baseUrl).toString(),
354
+ fetchImpl: params.fetchImpl,
355
+ init: params.init,
356
+ timeoutMs: params.timeoutMs,
357
+ maxRedirects: params.maxRedirects,
358
+ signal: params.signal,
359
+ policy: params.ssrfPolicy,
360
+ lookupFn: params.lookupFn,
361
+ auditContext: params.auditContext,
362
+ pinDns: params.pinDns
363
+ });
364
+ }
365
+ //#endregion
366
+ //#region extensions/tlon/src/urbit/auth.ts
367
+ async function authenticate(url, code, options = {}) {
368
+ const { response, release } = await urbitFetch({
369
+ baseUrl: url,
370
+ path: "/~/login",
371
+ init: {
372
+ method: "POST",
373
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
374
+ body: new URLSearchParams({ password: code }).toString()
375
+ },
376
+ ssrfPolicy: options.ssrfPolicy,
377
+ lookupFn: options.lookupFn,
378
+ fetchImpl: options.fetchImpl,
379
+ timeoutMs: options.timeoutMs ?? 15e3,
380
+ maxRedirects: 3,
381
+ auditContext: "tlon-urbit-login"
382
+ });
383
+ try {
384
+ if (!response.ok) throw new UrbitAuthError("auth_failed", `Login failed with status ${response.status}`);
385
+ await response.text().catch(() => {});
386
+ const cookie = response.headers.get("set-cookie");
387
+ if (!cookie) throw new UrbitAuthError("missing_cookie", "No authentication cookie received");
388
+ return cookie;
389
+ } finally {
390
+ await release();
391
+ }
392
+ }
393
+ //#endregion
394
+ //#region extensions/tlon/src/urbit/context.ts
395
+ function resolveShipFromHostname(hostname) {
396
+ const trimmed = hostname.trim().toLowerCase().replace(/\.$/, "");
397
+ if (!trimmed) return "";
398
+ if (trimmed.includes(".")) return trimmed.split(".")[0] ?? trimmed;
399
+ return trimmed;
400
+ }
401
+ function normalizeUrbitShip(ship, hostname) {
402
+ return (ship?.replace(/^~/, "") ?? resolveShipFromHostname(hostname)).trim();
403
+ }
404
+ function normalizeUrbitCookie(cookie) {
405
+ return cookie.split(";")[0] ?? cookie;
406
+ }
407
+ function getUrbitContext(url, ship) {
408
+ const validated = validateUrbitBaseUrl(url);
409
+ if (!validated.ok) throw new UrbitUrlError(validated.error);
410
+ return {
411
+ baseUrl: validated.baseUrl,
412
+ hostname: validated.hostname,
413
+ ship: normalizeUrbitShip(ship, validated.hostname)
414
+ };
415
+ }
416
+ function ssrfPolicyFromAllowPrivateNetwork(allowPrivateNetwork) {
417
+ return allowPrivateNetwork ? { allowPrivateNetwork: true } : void 0;
418
+ }
419
+ /**
420
+ * Get the default SSRF policy for image uploads.
421
+ * Uses a restrictive policy that blocks private networks by default.
422
+ */
423
+ function getDefaultSsrFPolicy() {}
424
+ //#endregion
425
+ //#region node_modules/.pnpm/@urbit+aura@3.0.0/node_modules/@urbit/aura/dist/aura.cjs.production.min.js
426
+ var require_aura_cjs_production_min = /* @__PURE__ */ __commonJSMin(((exports) => {
427
+ function n(n) {
428
+ let t = !0, [e, r, u] = n.split("..");
429
+ r = r || "0.0.0", u = u || "0000";
430
+ let [s, c, l] = e.slice(1).split(".");
431
+ "-" === s.at(-1) && (s = s.slice(0, -1), t = !1);
432
+ const [d, p, g] = r.split("."), h = u.split(".").map(((n) => BigInt("0x" + n)));
433
+ return function(n) {
434
+ const t = n.pos ? a + BigInt(n.year) : a - (BigInt(n.year) - 1n), e = (() => {
435
+ let e = i(t) ? f : o, r = n.time.day - 1n, a = n.month - 1n;
436
+ for (; 0n !== a;) {
437
+ const [n, ...t] = e;
438
+ r += BigInt(n), a -= 1n, e = t;
439
+ }
440
+ let u = !0, s = t;
441
+ for (; 1 == u;) s % 4n !== 0n ? (s -= 1n, r += i(s) ? 366n : 365n) : s % 100n !== 0n ? (s -= 4n, r += i(s) ? 1461n : 1460n) : s % 400n !== 0n ? (s -= 100n, r += i(s) ? 36525n : 36524n) : (r += s / 400n * (4n * 36524n + 1n), u = !1);
442
+ return r;
443
+ })();
444
+ return n.time.day = e, m(n.time);
445
+ }({
446
+ pos: t,
447
+ year: BigInt(s),
448
+ month: BigInt(c),
449
+ time: {
450
+ day: BigInt(l),
451
+ hour: BigInt(d),
452
+ minute: BigInt(p),
453
+ second: BigInt(g),
454
+ ms: h
455
+ }
456
+ });
457
+ }
458
+ function t(n) {
459
+ const t = {
460
+ day: 0n,
461
+ hour: 0n,
462
+ minute: 0n,
463
+ second: 0n,
464
+ ms: []
465
+ };
466
+ n = n.slice(1);
467
+ let [e, r] = n.split("..");
468
+ return r = r || "0000", t.ms = r.split(".").map(((n) => BigInt("0x" + n))), e.split(".").forEach(((e) => {
469
+ switch (e[0]) {
470
+ case "d":
471
+ t.day += BigInt(e.slice(1));
472
+ break;
473
+ case "h":
474
+ t.hour += BigInt(e.slice(1));
475
+ break;
476
+ case "m":
477
+ t.minute += BigInt(e.slice(1));
478
+ break;
479
+ case "s":
480
+ t.second += BigInt(e.slice(1));
481
+ break;
482
+ default: throw new Error("bad dr: " + n);
483
+ }
484
+ })), r = r || "0000", m(t);
485
+ }
486
+ Object.defineProperty(exports, "__esModule", { value: !0 });
487
+ const e = BigInt("170141184475152167957503069145530368000"), r = BigInt("18446744073709551616"), a = BigInt("292277024400");
488
+ function i(n) {
489
+ return n % 4n === 0n && n % 100n !== 0n || n % 400n === 0n;
490
+ }
491
+ const o = [
492
+ 31,
493
+ 28,
494
+ 31,
495
+ 30,
496
+ 31,
497
+ 30,
498
+ 31,
499
+ 31,
500
+ 30,
501
+ 31,
502
+ 30,
503
+ 31
504
+ ], f = [
505
+ 31,
506
+ 29,
507
+ 31,
508
+ 30,
509
+ 31,
510
+ 30,
511
+ 31,
512
+ 31,
513
+ 30,
514
+ 31,
515
+ 30,
516
+ 31
517
+ ], u = 86400n, s = 3600n, c = 60n, l = 146097n, d = 36524n;
518
+ function m(n) {
519
+ let t = n.second + u * n.day + s * n.hour + c * n.minute, e = n.ms, r = 0n, a = 3n;
520
+ for (; 0 !== e.length;) {
521
+ const [n, ...t] = e;
522
+ r += n << 16n * a, e = t, a -= 1n;
523
+ }
524
+ return r | t << 64n;
525
+ }
526
+ function p(n) {
527
+ let t = n >> 64n;
528
+ const e = (BigInt("0xffffffffffffffff") & n).toString(16).padStart(16, "0").match(/.{4}/g).map(((n) => BigInt("0x" + n)));
529
+ for (; 0n === e.at(-1);) e.pop();
530
+ let r = t / u;
531
+ t %= u;
532
+ let a = t / s;
533
+ t %= s;
534
+ let i = t / c;
535
+ return t %= c, {
536
+ ms: e,
537
+ day: r,
538
+ minute: i,
539
+ hour: a,
540
+ second: t
541
+ };
542
+ }
543
+ const g = (n, t) => ((n, t) => {
544
+ const e = Number(255n & t), r = Number((65280n & t) / 256n), a = String.fromCharCode(e) + String.fromCharCode(r);
545
+ return BigInt(((n, t) => {
546
+ let e, r, a, i, o, f, u, s;
547
+ for (e = 3 & n.length, r = n.length - e, a = t, o = 3432918353, f = 461845907, s = 0; s < r;) u = 255 & n.charCodeAt(s) | (255 & n.charCodeAt(++s)) << 8 | (255 & n.charCodeAt(++s)) << 16 | (255 & n.charCodeAt(++s)) << 24, ++s, u = (65535 & u) * o + (((u >>> 16) * o & 65535) << 16) & 4294967295, u = u << 15 | u >>> 17, u = (65535 & u) * f + (((u >>> 16) * f & 65535) << 16) & 4294967295, a ^= u, a = a << 13 | a >>> 19, i = 5 * (65535 & a) + ((5 * (a >>> 16) & 65535) << 16) & 4294967295, a = 27492 + (65535 & i) + ((58964 + (i >>> 16) & 65535) << 16);
548
+ switch (u = 0, e) {
549
+ case 3: u ^= (255 & n.charCodeAt(s + 2)) << 16;
550
+ case 2: u ^= (255 & n.charCodeAt(s + 1)) << 8;
551
+ case 1: u ^= 255 & n.charCodeAt(s), u = (65535 & u) * o + (((u >>> 16) * o & 65535) << 16) & 4294967295, u = u << 15 | u >>> 17, u = (65535 & u) * f + (((u >>> 16) * f & 65535) << 16) & 4294967295, a ^= u;
552
+ }
553
+ return a ^= n.length, a ^= a >>> 16, a = 2246822507 * (65535 & a) + ((2246822507 * (a >>> 16) & 65535) << 16) & 4294967295, a ^= a >>> 13, a = 3266489909 * (65535 & a) + ((3266489909 * (a >>> 16) & 65535) << 16) & 4294967295, a ^= a >>> 16, a >>> 0;
554
+ })(a, n));
555
+ })([
556
+ 3077398253,
557
+ 3995603712,
558
+ 2243735041,
559
+ 1261992695
560
+ ][n], t), h = (n) => y(4, 65535n, 65536n, 4294967295n, g, n), y = (n, t, e, r, a, i) => {
561
+ const o = b(n, t, e, a, i);
562
+ return o < r ? o : b(n, t, e, a, o);
563
+ }, b = (n, t, e, r, a) => {
564
+ const i = (a, o, f) => {
565
+ if (a > n) return n % 2 != 0 || f === t ? t * f + o : t * o + f;
566
+ {
567
+ const n = BigInt(r(a - 1, f).toString());
568
+ return i(a + 1, f, a % 2 != 0 ? (o + n) % t : (o + n) % e);
569
+ }
570
+ };
571
+ return i(1, a % t, a / t);
572
+ }, x = (n) => w(4, 65535n, 65536n, 4294967295n, g, n), w = (n, t, e, r, a, i) => {
573
+ const o = B(n, t, e, a, i);
574
+ return o < r ? o : B(n, t, e, a, o);
575
+ }, B = (n, t, e, r, a) => {
576
+ const i = (n, a, o) => {
577
+ if (n < 1) return t * o + a;
578
+ {
579
+ const f = r(n - 1, a);
580
+ return i(n - 1, n % 2 != 0 ? (o + t - f % t) % t : (o + e - f % e) % e, a);
581
+ }
582
+ }, o = n % 2 != 0 ? a / t : a % t, f = n % 2 != 0 ? a % t : a / t;
583
+ return i(n, f === t ? o : f, f === t ? f : o);
584
+ };
585
+ var I = {
586
+ F: g,
587
+ fe: b,
588
+ Fe: y,
589
+ feis: h,
590
+ fein: (n) => {
591
+ const t = (n) => {
592
+ const e = 4294967295n & n, r = 18446744069414584320n & n;
593
+ return n >= 65536n && n <= 4294967295n ? 65536n + h(n - 65536n) : n >= 4294967296n && n <= 18446744073709551615n ? r | t(e) : n;
594
+ };
595
+ return t(n);
596
+ },
597
+ fen: B,
598
+ Fen: w,
599
+ tail: x,
600
+ fynd: (n) => {
601
+ const t = (n) => {
602
+ const e = 4294967295n & n, r = 18446744069414584320n & n;
603
+ return n >= 65536n && n <= 4294967295n ? 65536n + x(n - 65536n) : n >= 4294967296n && n <= 18446744073709551615n ? r | t(e) : n;
604
+ };
605
+ return t(BigInt(n));
606
+ }
607
+ };
608
+ const v = /^~([a-z]{3}|([a-z]{6}(\-[a-z]{6}){0,3}(\-(\-[a-z]{6}){4})*))$/;
609
+ function S(n) {
610
+ const t = N(n), e = (n) => n.toString(2).padStart(8, "0"), r = t.reduce(((n, r, a) => a % 2 != 0 || 1 === t.length ? n + e(E.indexOf(r)) : n + e(C.indexOf(r))), ""), a = BigInt("0b" + r);
611
+ return I.fynd(a);
612
+ }
613
+ function $(n) {
614
+ const t = I.fein(n), e = Math.ceil(t.toString(16).length / 2), r = Math.ceil(t.toString(16).length / 4);
615
+ return "~" + (e <= 1 ? E[Number(t)] : function n(t, e, a) {
616
+ const i = 65535n & t, o = C[Number(i >> 8n)], f = E[Number(255n & i)];
617
+ return e === r ? a : n(t >> 16n, e + 1, o + f + (3 & e ? "-" : 0 === e ? "" : "--") + a);
618
+ }(t, 0, ""));
619
+ }
620
+ function A(n) {
621
+ let t;
622
+ return t = "bigint" == typeof n ? n : z(n), t <= 255n ? "czar" : t <= 65535n ? "king" : t <= 4294967295n ? "duke" : t <= 18446744073709551615n ? "earl" : "pawn";
623
+ }
624
+ function k(n) {
625
+ switch (n) {
626
+ case "czar": return "galaxy";
627
+ case "king": return "star";
628
+ case "duke": return "planet";
629
+ case "earl": return "moon";
630
+ case "pawn": return "comet";
631
+ }
632
+ }
633
+ function z(n) {
634
+ if (!function(n) {
635
+ return v.test(n) && j(n) && n === $(S(n));
636
+ }(n)) throw new Error("invalid @p literal: " + n);
637
+ return S(n);
638
+ }
639
+ const C = "\ndozmarbinwansamlitsighidfidlissogdirwacsabwissibrigsoldopmodfoglidhopdardorlorhodfolrintogsilmirholpaslacrovlivdalsatlibtabhanticpidtorbolfosdotlosdilforpilramtirwintadbicdifrocwidbisdasmidloprilnardapmolsanlocnovsitnidtipsicropwitnatpanminritpodmottamtolsavposnapnopsomfinfonbanmorworsipronnorbotwicsocwatdolmagpicdavbidbaltimtasmalligsivtagpadsaldivdactansidfabtarmonranniswolmispallasdismaprabtobrollatlonnodnavfignomnibpagsopralbilhaddocridmocpacravripfaltodtiltinhapmicfanpattaclabmogsimsonpinlomrictapfirhasbosbatpochactidhavsaplindibhosdabbitbarracparloddosbortochilmactomdigfilfasmithobharmighinradmashalraglagfadtopmophabnilnosmilfopfamdatnoldinhatnacrisfotribhocnimlarfitwalrapsarnalmoslandondanladdovrivbacpollaptalpitnambonrostonfodponsovnocsorlavmatmipfip".match(/.{1,3}/g), E = "\nzodnecbudwessevpersutletfulpensytdurwepserwylsunrypsyxdyrnuphebpeglupdepdysputlughecryttyvsydnexlunmeplutseppesdelsulpedtemledtulmetwenbynhexfebpyldulhetmevruttylwydtepbesdexsefwycburderneppurrysrebdennutsubpetrulsynregtydsupsemwynrecmegnetsecmulnymtevwebsummutnyxrextebfushepbenmuswyxsymselrucdecwexsyrwetdylmynmesdetbetbeltuxtugmyrpelsyptermebsetdutdegtexsurfeltudnuxruxrenwytnubmedlytdusnebrumtynseglyxpunresredfunrevrefmectedrusbexlebduxrynnumpyxrygryxfeptyrtustyclegnemfermertenlusnussyltecmexpubrymtucfyllepdebbermughuttunbylsudpemdevlurdefbusbeprunmelpexdytbyttyplevmylwedducfurfexnulluclennerlexrupnedlecrydlydfenwelnydhusrelrudneshesfetdesretdunlernyrsebhulrylludremlysfynwerrycsugnysnyllyndyndemluxfedsedbecmunlyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes".match(/.{1,3}/g);
640
+ function N(n) {
641
+ return n.replace(/[\^~-]/g, "").match(/.{1,3}/g) || [];
642
+ }
643
+ function j(n) {
644
+ const t = N(n);
645
+ return !(t.length % 2 != 0 && 1 !== t.length) && t.every(((n, e) => e % 2 != 0 || 1 === t.length ? E.includes(n) : C.includes(n)));
646
+ }
647
+ function _(n, t) {
648
+ let e = [], r = [e];
649
+ for (let a = 0; a < n.length; a++) e.length < t ? e.push(n[a]) : (e = [n[a]], r.push(e));
650
+ return r;
651
+ }
652
+ function q(n, t) {
653
+ return n = M(n), function(n, t, e) {
654
+ if ("nan" === n) return function(n, t) {
655
+ return O(BigInt(n + 1)) << BigInt(t - 1);
656
+ }(t, e);
657
+ if ("inf" === n) return U(!0, t, e);
658
+ if ("-inf" === n) return U(!1, t, e);
659
+ let r = 0, a = !0;
660
+ "-" === n[r] && (a = !1, r++);
661
+ let i = "";
662
+ for (; "." !== n[r] && "e" !== n[r] && void 0 !== n[r];) i += n[r++];
663
+ "." === n[r] && r++;
664
+ let o = "";
665
+ for (; "e" !== n[r] && void 0 !== n[r];) o += n[r++];
666
+ "e" === n[r] && r++;
667
+ let f = !0;
668
+ "-" === n[r] && (f = !1, r++);
669
+ let u = "";
670
+ for (; void 0 !== n[r];) u += n[r++];
671
+ return BigInt("0b" + function(n, t, e, r, a, i, o) {
672
+ return 0 !== o && (i ? (r += a.padEnd(o, "0").slice(0, o), a = a.slice(o)) : (a = r.padStart(o, "0").slice(-o) + a, r = r.slice(0, -o))), function(n, t, e, r, a, i) {
673
+ function o(n) {
674
+ return console.warn(n), 1;
675
+ }
676
+ const f = 2 ** (t - 1) - 1, u = 1 - f, s = f, c = u - n, l = 2 * f + 1 + n + 3, d = new Array(l), m = 10n ** a;
677
+ var p, g, h, y, b, x, w = 0, B = !e;
678
+ for (p = l; p; d[--p] = 0);
679
+ for (p = f + 2; r && p; d[--p] = 1n & r, r >>= 1n);
680
+ for (p = f + 1; i > 0n && p < l; (d[++p] = (i *= 2n) >= m ? 1 : 0) && (i -= m));
681
+ for (p = -1; ++p < l && !d[p];);
682
+ if (d[(g = n - 1 + (p = (w = f + 1 - p) >= u && w <= s ? p + 1 : f + 1 - (w = u - 1))) + 1]) {
683
+ if (!(h = d[g])) for (y = g + 2; !h && y < l; h = d[y++]);
684
+ for (y = g + 1; h && --y >= 0; (d[y] = (d[y] ? 0 : 1) - 0) && (h = 0));
685
+ }
686
+ for (p = p - 2 < 0 ? -1 : p - 3; ++p < l && !d[p];);
687
+ for ((w = f + 1 - p) >= u && w <= s ? ++p : w < u && (w != f + 1 - l && w < c && o("r.construct underflow"), p = f + 1 - (w = u - 1)), r && (o(r ? "r.construct overflow" : "r.construct"), w = s + 1, p = f + 2), x = Math.abs(w + f), y = t + 1, b = ""; --y; b = (1 & x) + b, x = x >>= 1);
688
+ return (B ? "1" : "0") + b + d.slice(p, p + n).join("");
689
+ }(t, n, e, BigInt(r), BigInt(a.length), BigInt(a));
690
+ }(t, e, a, i, o, f, Number(u)));
691
+ }(t.slice(n.l.length), n.w, n.p);
692
+ }
693
+ function F(n, t) {
694
+ return (n = M(n)).l + function(n) {
695
+ if ("n" === n.t) return "nan";
696
+ if ("i" === n.t) return n.s ? "inf" : "-inf";
697
+ let t;
698
+ return n.e - 4 > 0 || n.e + 2 < 0 ? t = 1 : (t = n.e + 1, n.e = 0), (n.s ? "" : "-") + function(n, t) {
699
+ const e = Math.abs(n);
700
+ if (n <= 0) return "0." + "".padEnd(e, "0") + t;
701
+ {
702
+ const n = t.length;
703
+ return e >= n ? t + "".padEnd(e - n, "0") : t.slice(0, e) + "." + t.slice(e);
704
+ }
705
+ }(t, n.a) + (0 === n.e ? "" : "e" + n.e.toString());
706
+ }(function(n, t, e) {
707
+ const r = O(e), a = O(t), i = n & r, o = n >> BigInt(e) & a, f = 0n === (n >> BigInt(t + e) & 1n);
708
+ let u, s, c, l;
709
+ if (o === a) return 0n === i ? {
710
+ t: "i",
711
+ s: f
712
+ } : { t: "n" };
713
+ 0n !== o ? (u = 1n << BigInt(e) | i, s = o - (2n ** (t - 1n) - 1n) - e, c = Number(e), l = 1n !== o && 0n === i) : (u = i, s = 1n - (2n ** (t - 1n) - 1n) - e, c = u.toString(2).length - 1, l = !1);
714
+ const d = (2n ** e).toString(10).length + 1, m = function(n, t, e, r, a, i, o) {
715
+ const f = BigInt(t);
716
+ let u, s, c, l, d = 0, m = new Array(o).fill("0"), p = 0;
717
+ if (0n === n) return m[0] = "0", p = 0, {
718
+ digits: m.slice(0, 1).join(""),
719
+ outExponent: p
720
+ };
721
+ r ? t > 0 ? (s = 4n * n, s <<= f, u = 4n, c = 1n << f, l = 1n << f + 1n) : (s = 4n * n, u = 1n << -f + 2n, c = 1n, l = 2n) : t > 0 ? (s = 2n * n, s <<= f, u = 2n, c = 1n << f, l = c) : (s = 2n * n, u = 1n << BigInt(1 - t), c = 1n, l = c);
722
+ let g = Math.ceil(.3010299956639812 * (e + t) - .69);
723
+ if (g > 0) u *= BigInt(10) ** BigInt(g);
724
+ else if (g < 0) {
725
+ const n = BigInt(10) ** BigInt(-g);
726
+ s *= n, c *= n, l !== c && (l *= c);
727
+ }
728
+ s >= u ? g += 1 : (s *= 10n, c *= 10n, l !== c && (l *= 10n));
729
+ let h = g - o;
730
+ p = g - 1;
731
+ let y = !1, b = !1, x = 0;
732
+ for (; g -= 1, x = Number(s / u), s %= u, y = s < c, b = s + l > u, !y && !b && g !== h;) m[d] = String.fromCharCode("0".charCodeAt(0) + x), d += 1, s *= 10n, c *= 10n, l !== c && (l *= 10n);
733
+ let w = y;
734
+ if (y === b) {
735
+ s *= 2n;
736
+ let n = s < u ? -1 : s > u ? 1 : 0;
737
+ w = n < 0, 0 === n && (w = 0 == (1 & x));
738
+ }
739
+ if (w) m[d] = String.fromCharCode("0".charCodeAt(0) + x), d += 1;
740
+ else if (9 === x) for (;;) {
741
+ if (0 === d) {
742
+ m[d] = "1", d += 1, p += 1;
743
+ break;
744
+ }
745
+ if (d -= 1, "9" !== m[d]) {
746
+ m[d] = String.fromCharCode(m[d].charCodeAt(0) + 1), d += 1;
747
+ break;
748
+ }
749
+ }
750
+ else m[d] = String.fromCharCode("0".charCodeAt(0) + x + 1), d += 1;
751
+ return {
752
+ digits: m.slice(0, d).join(""),
753
+ outExponent: p
754
+ };
755
+ }(u, Number(s), c, l, 0, 0, d);
756
+ return {
757
+ t: "d",
758
+ s: f,
759
+ e: m.outExponent,
760
+ a: m.digits
761
+ };
762
+ }(t, BigInt(n.w), BigInt(n.p)));
763
+ }
764
+ function M(n) {
765
+ return "h" === n ? {
766
+ w: 5,
767
+ p: 10,
768
+ l: ".~~"
769
+ } : "s" === n ? {
770
+ w: 8,
771
+ p: 23,
772
+ l: "."
773
+ } : "d" === n ? {
774
+ w: 11,
775
+ p: 52,
776
+ l: ".~"
777
+ } : "q" === n ? {
778
+ w: 15,
779
+ p: 112,
780
+ l: ".~~~"
781
+ } : n;
782
+ }
783
+ function O(n) {
784
+ return 2n ** n - 1n;
785
+ }
786
+ function U(n, t, e) {
787
+ return O(BigInt(n ? t : t + 1)) << BigInt(e);
788
+ }
789
+ function Z(n, t, e, r, a) {
790
+ return void 0 === a && (a = !1), new RegExp(`^${a ? "\\-\\-?" : ""}${n}(0|${0 === r ? t : `${t}${e}{0,${r - 1}}`}${0 === r ? `${e}*` : `(\\.${e}{${r}})*`})$`);
791
+ }
792
+ function P(n) {
793
+ return new RegExp(`^\\.~{${n}}(nan|\\-?(inf|(0|[1-9][0-9]*)(\\.[0-9]+)?(e\\-?(0|[1-9][0-9]*))?))$`);
794
+ }
795
+ const R = {
796
+ c: /^~\-((~[0-9a-fA-F]+\.)|(~[~\.])|[0-9a-z\-\._])*$/,
797
+ da: /^~(0|[1-9][0-9]*)\-?\.0*([1-9]|1[0-2])\.0*[1-9][0-9]*(\.\.([0-9]+)\.([0-9]+)\.([0-9]+)(\.(\.[0-9a-f]{4})+)?)?$/,
798
+ dr: /^~((d|h|m|s)(0|[1-9][0-9]*))(\.(d|h|m|s)(0|[1-9][0-9]*))*(\.(\.[0-9a-f]{4})+)?$/,
799
+ f: /^\.(y|n)$/,
800
+ if: /^(\.(0|[1-9][0-9]{0,2})){4}$/,
801
+ is: /^(\.(0|[1-9a-fA-F][0-9a-fA-F]{0,3})){8}$/,
802
+ n: /^~$/,
803
+ p: v,
804
+ q: /^\.~(([a-z]{3}|[a-z]{6})(\-[a-z]{6})*)$/,
805
+ rd: P(1),
806
+ rh: P(2),
807
+ rq: P(3),
808
+ rs: P(0),
809
+ sb: Z("0b", "1", "[01]", 4, !0),
810
+ sd: Z("", "[1-9]", "[0-9]", 3, !0),
811
+ si: Z("0i", "[1-9]", "[0-9]", 0, !0),
812
+ sv: Z("0v", "[1-9a-v]", "[0-9a-v]", 5, !0),
813
+ sw: Z("0w", "[1-9a-zA-Z~-]", "[0-9a-zA-Z~-]", 5, !0),
814
+ sx: Z("0x", "[1-9a-f]", "[0-9a-f]", 4, !0),
815
+ t: /^~~((~[0-9a-fA-F]+\.)|(~[~\.])|[0-9a-z\-\._])*$/,
816
+ ta: /^~\.[0-9a-z\-\.~_]*$/,
817
+ tas: /^[a-z][a-z0-9\-]*$/,
818
+ ub: Z("0b", "1", "[01]", 4),
819
+ ud: Z("", "[1-9]", "[0-9]", 3),
820
+ ui: Z("0i", "[1-9]", "[0-9]", 0),
821
+ uv: Z("0v", "[1-9a-v]", "[0-9a-v]", 5),
822
+ uw: Z("0w", "[1-9a-zA-Z~-]", "[0-9a-zA-Z~-]", 5),
823
+ ux: Z("0x", "[1-9a-f]", "[0-9a-f]", 4)
824
+ }, T = D;
825
+ function D(n, t) {
826
+ const e = H(n, t);
827
+ if (!e) throw new Error("slav: failed to parse @" + n + " from string: " + t);
828
+ return e;
829
+ }
830
+ const G = H;
831
+ function H(n, t) {
832
+ if (n in R && !R[n].test(t)) return null;
833
+ const e = J(t);
834
+ return e && "dime" === e.type && e.aura === n ? e.atom : null;
835
+ }
836
+ function J(e) {
837
+ if ("" === e) return null;
838
+ const r = e[0];
839
+ if (r >= "a" && r <= "z") return R.tas.test(e) ? {
840
+ type: "dime",
841
+ aura: "tas",
842
+ atom: Q(e)
843
+ } : null;
844
+ if (r >= "0" && r <= "9") {
845
+ const n = K(e);
846
+ return n ? {
847
+ type: "dime",
848
+ ...n
849
+ } : null;
850
+ }
851
+ if ("-" === r) {
852
+ let n = !0;
853
+ "-" == e[1] ? e = e.slice(2) : (e = e.slice(1), n = !1);
854
+ const t = K(e);
855
+ return t ? (n ? t.atom = 2n * t.atom : 0n !== t.atom && (t.atom = 1n + 2n * (t.atom - 1n)), {
856
+ type: "dime",
857
+ aura: t.aura.replace("u", "s"),
858
+ atom: t.atom
859
+ }) : null;
860
+ }
861
+ if ("." === r) {
862
+ if (".y" === e) return {
863
+ type: "dime",
864
+ aura: "f",
865
+ atom: 0n
866
+ };
867
+ if (".n" === e) return {
868
+ type: "dime",
869
+ aura: "f",
870
+ atom: 1n
871
+ };
872
+ if (R.is.test(e)) {
873
+ const n = e.slice(1).split(".").reduce(((n, t) => n + t.padStart(4, "0")), "");
874
+ return {
875
+ type: "dime",
876
+ aura: "is",
877
+ atom: BigInt("0x" + n)
878
+ };
879
+ }
880
+ if (R.if.test(e)) return {
881
+ type: "dime",
882
+ aura: "if",
883
+ atom: e.slice(1).split(".").reduce(((n, t, e) => n + (BigInt(t) << BigInt(8 * (3 - e)))), 0n)
884
+ };
885
+ if ("~" === e[1] && (R.rd.test(e) || R.rh.test(e) || R.rq.test(e)) || R.rs.test(e)) {
886
+ let n, t = 0;
887
+ for (; "~" === e[t + 1];) t++;
888
+ switch (t) {
889
+ case 0:
890
+ n = "rs";
891
+ break;
892
+ case 1:
893
+ n = "rd";
894
+ break;
895
+ case 2:
896
+ n = "rh";
897
+ break;
898
+ case 3:
899
+ n = "rq";
900
+ break;
901
+ default: throw new Error("parsing invalid @r*");
902
+ }
903
+ return {
904
+ type: "dime",
905
+ aura: n,
906
+ atom: q(n[1], e)
907
+ };
908
+ }
909
+ if ("~" === e[1] && R.q.test(e)) {
910
+ const n = function(n) {
911
+ try {
912
+ return function(n) {
913
+ const t = n.slice(2).split("-"), e = (n) => {
914
+ if (n < 0) throw new Error("malformed @q");
915
+ return n.toString(16).padStart(2, "0");
916
+ }, r = t.map(((n, t) => {
917
+ let r = function(n, t) {
918
+ return [t.slice(0, 3), t.slice(3)];
919
+ }(0, n);
920
+ return "" === r[1] && 0 === t ? e(E.indexOf(r[0])) : e(C.indexOf(r[0])) + e(E.indexOf(r[1]));
921
+ }));
922
+ return BigInt("0x" + (0 === n.length ? "00" : r.join("")));
923
+ }(n);
924
+ } catch (n) {
925
+ return null;
926
+ }
927
+ }(e);
928
+ return null === n ? null : {
929
+ type: "dime",
930
+ aura: "q",
931
+ atom: n
932
+ };
933
+ }
934
+ if ("_" === e[1] && /^\.(_([0-9a-zA-Z\-\.]|~\-|~~)+)*__$/.test(e)) {
935
+ const n = e.slice(1, -2).split("_").slice(1).map(((n) => J(n = n.replaceAll("~-", "_").replaceAll("~~", "~"))));
936
+ return n.some(((n) => null === n)) ? null : {
937
+ type: "many",
938
+ list: n
939
+ };
940
+ }
941
+ return null;
942
+ }
943
+ if ("~" === r) {
944
+ if ("~" === e) return {
945
+ type: "dime",
946
+ aura: "n",
947
+ atom: 0n
948
+ };
949
+ if (R.da.test(e)) return {
950
+ type: "dime",
951
+ aura: "da",
952
+ atom: n(e)
953
+ };
954
+ if (R.dr.test(e)) return {
955
+ type: "dime",
956
+ aura: "dr",
957
+ atom: t(e)
958
+ };
959
+ if (R.p.test(e)) {
960
+ const n = function(n) {
961
+ if (!v.test(n) || !j(n)) return null;
962
+ const t = S(n);
963
+ return n === $(t) ? t : null;
964
+ }(e);
965
+ return null === n ? null : {
966
+ type: "dime",
967
+ aura: "p",
968
+ atom: n
969
+ };
970
+ }
971
+ return "." === e[1] && R.ta.test(e) ? {
972
+ type: "dime",
973
+ aura: "ta",
974
+ atom: Q(e.slice(2))
975
+ } : "~" === e[1] && R.t.test(e) ? {
976
+ type: "dime",
977
+ aura: "t",
978
+ atom: Q(L(e.slice(2)))
979
+ } : "-" === e[1] && R.c.test(e) ? /^~\-~[0-9a-f]+\.$/.test(e) ? {
980
+ type: "dime",
981
+ aura: "c",
982
+ atom: BigInt("0x" + e.slice(3, -1))
983
+ } : {
984
+ type: "dime",
985
+ aura: "c",
986
+ atom: Q(L(e.slice(2)))
987
+ } : "0" === e[1] && /^~0[0-9a-v]+$/.test(e) ? {
988
+ type: "blob",
989
+ jam: X(5, W, e.slice(2))
990
+ } : null;
991
+ }
992
+ return null;
993
+ }
994
+ function K(n) {
995
+ switch (n.slice(0, 2)) {
996
+ case "0b": return R.ub.test(n) ? {
997
+ aura: "ub",
998
+ atom: BigInt(n.replaceAll(".", ""))
999
+ } : null;
1000
+ case "0c": return console.log("aura-js: @uc parsing unsupported (bisk)"), null;
1001
+ case "0i": return R.ui.test(n) ? {
1002
+ aura: "ui",
1003
+ atom: BigInt(n.slice(2))
1004
+ } : null;
1005
+ case "0x": return R.ux.test(n) ? {
1006
+ aura: "ux",
1007
+ atom: BigInt(n.replaceAll(".", ""))
1008
+ } : null;
1009
+ case "0v": return R.uv.test(n) ? {
1010
+ aura: "uv",
1011
+ atom: X(5, W, n.slice(2))
1012
+ } : null;
1013
+ case "0w": return R.uw.test(n) ? {
1014
+ aura: "uw",
1015
+ atom: X(6, V, n.slice(2))
1016
+ } : null;
1017
+ default: return R.ud.test(n) ? {
1018
+ aura: "ud",
1019
+ atom: BigInt(n.replaceAll(".", ""))
1020
+ } : null;
1021
+ }
1022
+ }
1023
+ function L(n) {
1024
+ let t = "", e = 0;
1025
+ for (; e < n.length;) switch (n[e]) {
1026
+ case ".":
1027
+ t += " ", e++;
1028
+ continue;
1029
+ case "~": switch (n[++e]) {
1030
+ case "~":
1031
+ t += "~", e++;
1032
+ continue;
1033
+ case ".":
1034
+ t += ".", e++;
1035
+ continue;
1036
+ default:
1037
+ let r = 0;
1038
+ do
1039
+ r = r << 4 | Number.parseInt(n[e++], 16);
1040
+ while ("." !== n[e]);
1041
+ t += String.fromCodePoint(r), e++;
1042
+ continue;
1043
+ }
1044
+ default:
1045
+ t += n[e++];
1046
+ continue;
1047
+ }
1048
+ return t;
1049
+ }
1050
+ function Q(n) {
1051
+ return function(n) {
1052
+ if (0 === n.length) return 0n;
1053
+ if ("undefined" != typeof Buffer) return BigInt("0x" + Buffer.from(n.reverse()).toString("hex"));
1054
+ let t, e = [];
1055
+ for (var r = n.length - 1; r >= 0; --r) t = n[r], e.push(t < 16 ? "0" + t.toString(16) : t.toString(16));
1056
+ return BigInt("0x" + e.join(""));
1057
+ }(new TextEncoder().encode(n));
1058
+ }
1059
+ const V = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-~", W = "0123456789abcdefghijklmnopqrstuv";
1060
+ function X(n, t, e) {
1061
+ let r = 0n;
1062
+ const a = BigInt(n);
1063
+ for (; "" !== e;) "." !== e[0] && (r = (r << a) + BigInt(t.indexOf(e[0]))), e = e.slice(1);
1064
+ return r;
1065
+ }
1066
+ const Y = nn;
1067
+ function nn(n, t) {
1068
+ return tn({
1069
+ type: "dime",
1070
+ aura: n,
1071
+ atom: t
1072
+ });
1073
+ }
1074
+ function tn(n) {
1075
+ switch (n.type) {
1076
+ case "blob": return "~0" + n.jam.toString(32);
1077
+ case "many": return "." + n.list.reduce(((n, t) => n + "_" + tn(t).replaceAll("~", "~~").replaceAll("_", "~-")), "") + "__";
1078
+ case "dime": switch (n.aura[0]) {
1079
+ case "c": return n.atom < 127n ? "~-" + rn(String.fromCharCode(Number(n.atom))) : "~-~" + n.atom.toString(16) + ".";
1080
+ case "d": switch (n.aura[1]) {
1081
+ case "a": return function(n) {
1082
+ const { pos: t, year: e, month: r, time: i } = function(n) {
1083
+ const t = p(n), [e, r, i] = function(n) {
1084
+ let t = 0n, e = 0n, r = !1;
1085
+ t = n / l, (n %= l) < d + 1n ? r = !0 : (r = !1, e = 1n, e += (n -= d + 1n) / d, n %= d);
1086
+ let a = 400n * t + 100n * e, i = !0;
1087
+ for (; 1 == i;) {
1088
+ let t = r ? 366n : 365n;
1089
+ if (n < t) {
1090
+ i = !1;
1091
+ let e = 0n;
1092
+ for (;;) {
1093
+ let t = BigInt((r ? f : o)[Number(e)]);
1094
+ if (n < t) return [
1095
+ a,
1096
+ e + 1n,
1097
+ n + 1n
1098
+ ];
1099
+ e += 1n, n -= t;
1100
+ }
1101
+ } else a += 1n, n -= t, r = a % 4n === 0n;
1102
+ }
1103
+ return [
1104
+ 0n,
1105
+ 0n,
1106
+ 0n
1107
+ ];
1108
+ }(t.day);
1109
+ t.day = i;
1110
+ const u = e > a;
1111
+ return {
1112
+ pos: u,
1113
+ year: u ? e - a : a + 1n - e,
1114
+ month: r,
1115
+ time: t
1116
+ };
1117
+ }(n);
1118
+ let u = `~${e}${t ? "" : "-"}.${r}.${i.day}`;
1119
+ return 0n === i.hour && 0n === i.minute && 0n === i.second && 0 === i.ms.length || (u += `..${i.hour.toString().padStart(2, "0")}.${i.minute.toString().padStart(2, "0")}.${i.second.toString().padStart(2, "0")}`, 0 !== i.ms.length && (u += `..${i.ms.map(((n) => n.toString(16).padStart(4, "0"))).join(".")}`)), u;
1120
+ }(n.atom);
1121
+ case "r": return function(n) {
1122
+ if (0n === n) return "~s0";
1123
+ const { day: t, hour: e, minute: r, second: a, ms: i } = p(n);
1124
+ let o = [];
1125
+ return 0n !== t && o.push("d" + t.toString()), 0n !== e && o.push("h" + e.toString()), 0n !== r && o.push("m" + r.toString()), 0n !== a && o.push("s" + a.toString()), 0 !== i.length && (0 === o.length && o.push("s0"), o.push("." + i.map(((n) => n.toString(16).padStart(4, "0"))).join("."))), "~" + o.join(".");
1126
+ }(n.atom);
1127
+ default: return en(n.atom);
1128
+ }
1129
+ case "f": switch (n.atom) {
1130
+ case 0n: return ".y";
1131
+ case 1n: return ".n";
1132
+ default: return en(n.atom);
1133
+ }
1134
+ case "n": return "~";
1135
+ case "i": switch (n.aura[1]) {
1136
+ case "f": return "." + fn(n.atom, 1, 4, 10);
1137
+ case "s": return "." + fn(n.atom, 2, 8, 16);
1138
+ default: return en(n.atom);
1139
+ }
1140
+ case "p": return $(n.atom);
1141
+ case "q": return function(n) {
1142
+ const t = n.toString(16), e = t.length, r = Buffer.from(t.padStart(e + e % 2, "0"), "hex"), a = r.length % 2 != 0 && r.length > 1 ? [[r[0]]].concat(_(Array.from(r.slice(1)), 2)) : _(Array.from(r), 2);
1143
+ return a.reduce(((n, t) => {
1144
+ return n + (".~" === n ? "" : "-") + ((e = t).length % 2 != 0 && a.length > 1 ? void 0 === (r = e)[1] ? E[r[0]] : C[r[0]] + E[r[1]] : ((n) => void 0 === n[1] ? E[n[0]] : C[n[0]] + E[n[1]])(e));
1145
+ var e, r;
1146
+ }), ".~");
1147
+ }(n.atom);
1148
+ case "r": switch (n.aura[1]) {
1149
+ case "d": return F("d", n.atom);
1150
+ case "h": return F("h", n.atom);
1151
+ case "q": return F("q", n.atom);
1152
+ case "s": return F("s", n.atom);
1153
+ default: return en(n.atom);
1154
+ }
1155
+ case "u": switch (n.aura[1]) {
1156
+ case "c": throw new Error("aura-js: @uc rendering unsupported");
1157
+ case "b": return "0b" + on(n.atom.toString(2), 4);
1158
+ case "i": return "0i" + n.atom.toString(10).padStart(1, "0");
1159
+ case "x": return "0x" + on(n.atom.toString(16), 4);
1160
+ case "v": return "0v" + on(n.atom.toString(32), 5);
1161
+ case "w": return "0w" + on(function(n, t, e) {
1162
+ if (0n === e) return t[0];
1163
+ let r = "";
1164
+ const a = BigInt(6);
1165
+ for (; 0n !== e;) r = t[Number(BigInt.asUintN(6, e))] + r, e >>= a;
1166
+ return r;
1167
+ }(0, an, n.atom), 5);
1168
+ default: return on(n.atom.toString(10), 3);
1169
+ }
1170
+ case "s":
1171
+ const t = 1n & n.atom;
1172
+ return n.atom = t + (n.atom >> 1n), n.aura = n.aura.replace("s", "u"), (0n === t ? "--" : "-") + tn(n);
1173
+ case "t": return "a" === n.aura[1] ? "s" === n.aura[2] ? un(n.atom) : "~." + un(n.atom) : "~~" + rn(un(n.atom));
1174
+ default: return en(n.atom);
1175
+ }
1176
+ }
1177
+ }
1178
+ function en(n) {
1179
+ return "0x" + function(n, t) {
1180
+ return t.toString(16).padStart(1, "0");
1181
+ }(0, n);
1182
+ }
1183
+ function rn(n) {
1184
+ let t = "";
1185
+ for (let e = 0; e < n.length; e += 1) {
1186
+ const r = n[e];
1187
+ let a = "";
1188
+ switch (r) {
1189
+ case " ":
1190
+ a = ".";
1191
+ break;
1192
+ case ".":
1193
+ a = "~.";
1194
+ break;
1195
+ case "~":
1196
+ a = "~~";
1197
+ break;
1198
+ default: {
1199
+ const t = n.codePointAt(e);
1200
+ if (!t) break;
1201
+ t > 65535 && (e += 1), a = t >= 97 && t <= 122 || t >= 48 && t <= 57 || "-" === r ? r : `~${t.toString(16)}.`;
1202
+ }
1203
+ }
1204
+ t += a;
1205
+ }
1206
+ return t;
1207
+ }
1208
+ const an = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-~";
1209
+ function on(n, t) {
1210
+ return n.replace(new RegExp(`(?=(?:.{${t}})+$)(?!^)`, "g"), ".");
1211
+ }
1212
+ function fn(n, t, e, r) {
1213
+ void 0 === r && (r = 10);
1214
+ let a = "";
1215
+ const i = 8n * BigInt(t), o = (1n << i) - 1n;
1216
+ for (; e-- > 0;) "" !== a && (a = "." + a), a = (n & o).toString(r) + a, n >>= i;
1217
+ return a;
1218
+ }
1219
+ function un(n) {
1220
+ return new TextDecoder("utf-8").decode(function(n) {
1221
+ if (0n === n) return new Uint8Array(0);
1222
+ const t = n.toString(16), e = t.length % 2 == 0 ? t : "0" + t, r = new Uint8Array(e.length / 2);
1223
+ for (let n = 0; n < e.length; n += 2) {
1224
+ const t = e.slice(n, n + 2), a = parseInt(t, 16) << 24 >> 24;
1225
+ r[n / 2] = a;
1226
+ }
1227
+ return r;
1228
+ }(n).reverse());
1229
+ }
1230
+ const sn = {
1231
+ toSeconds: function(n) {
1232
+ const { day: t, hour: e, minute: r, second: a } = p(n);
1233
+ return 60n * (60n * (24n * t + e) + r) + a;
1234
+ },
1235
+ fromSeconds: function(n) {
1236
+ return m({
1237
+ day: 0n,
1238
+ hour: 0n,
1239
+ minute: 0n,
1240
+ second: n,
1241
+ ms: []
1242
+ });
1243
+ }
1244
+ }, cn = {
1245
+ cite: function(n) {
1246
+ let t;
1247
+ return t = "bigint" == typeof n ? n : z(n), t <= 4294967295n ? $(t) : t <= 18446744073709551615n ? $(4294967295n & t).replace("-", "^") : $(BigInt("0x" + t.toString(16).slice(0, 4))) + "_" + $(65535n & t).slice(1);
1248
+ },
1249
+ sein: function(n) {
1250
+ let t;
1251
+ t = "bigint" == typeof n ? n : z(n);
1252
+ let e = A(t);
1253
+ const r = "czar" === e ? t : "king" === e ? 255n & t : "duke" === e ? 65535n & t : "earl" === e ? 4294967295n & t : 65535n & t;
1254
+ return "bigint" == typeof n ? r : $(r);
1255
+ },
1256
+ clan: A,
1257
+ kind: function(n) {
1258
+ return k(A(n));
1259
+ },
1260
+ rankToSize: k,
1261
+ sizeToRank: function(n) {
1262
+ switch (n) {
1263
+ case "galaxy": return "czar";
1264
+ case "star": return "king";
1265
+ case "planet": return "duke";
1266
+ case "moon": return "earl";
1267
+ case "comet": return "pawn";
1268
+ }
1269
+ }
1270
+ };
1271
+ exports.da = {
1272
+ toUnix: function(n) {
1273
+ return Math.round(Number(1000n * (r / 2000n + (n - e)) / r));
1274
+ },
1275
+ fromUnix: function(n) {
1276
+ return e + BigInt(n) * r / 1000n;
1277
+ }
1278
+ }, exports.dr = sn, exports.nuck = J, exports.p = cn, exports.parse = T, exports.rend = tn, exports.render = Y, exports.scot = nn, exports.slav = D, exports.slaw = H, exports.tryParse = G, exports.valid = function(n, t) {
1279
+ return null !== H(n, t);
1280
+ };
1281
+ }));
1282
+ //#endregion
1283
+ //#region extensions/tlon/src/urbit/story.ts
1284
+ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
1285
+ module.exports = require_aura_cjs_production_min();
1286
+ })))();
1287
+ /**
1288
+ * Parse inline markdown formatting (bold, italic, code, links, mentions)
1289
+ */
1290
+ function parseInlineMarkdown(text) {
1291
+ const result = [];
1292
+ let remaining = text;
1293
+ while (remaining.length > 0) {
1294
+ const shipMatch = remaining.match(/^(~[a-z][-a-z0-9]*)/);
1295
+ if (shipMatch) {
1296
+ result.push({ ship: shipMatch[1] });
1297
+ remaining = remaining.slice(shipMatch[0].length);
1298
+ continue;
1299
+ }
1300
+ const boldMatch = remaining.match(/^\*\*(.+?)\*\*|^__(.+?)__/);
1301
+ if (boldMatch) {
1302
+ const content = boldMatch[1] || boldMatch[2];
1303
+ result.push({ bold: parseInlineMarkdown(content) });
1304
+ remaining = remaining.slice(boldMatch[0].length);
1305
+ continue;
1306
+ }
1307
+ const italicsMatch = remaining.match(/^\*([^*]+?)\*|^_([^_]+?)_(?![a-zA-Z0-9])/);
1308
+ if (italicsMatch) {
1309
+ const content = italicsMatch[1] || italicsMatch[2];
1310
+ result.push({ italics: parseInlineMarkdown(content) });
1311
+ remaining = remaining.slice(italicsMatch[0].length);
1312
+ continue;
1313
+ }
1314
+ const strikeMatch = remaining.match(/^~~(.+?)~~/);
1315
+ if (strikeMatch) {
1316
+ result.push({ strike: parseInlineMarkdown(strikeMatch[1]) });
1317
+ remaining = remaining.slice(strikeMatch[0].length);
1318
+ continue;
1319
+ }
1320
+ const codeMatch = remaining.match(/^`([^`]+)`/);
1321
+ if (codeMatch) {
1322
+ result.push({ "inline-code": codeMatch[1] });
1323
+ remaining = remaining.slice(codeMatch[0].length);
1324
+ continue;
1325
+ }
1326
+ const linkMatch = remaining.match(/^\[([^\]]+)\]\(([^)]+)\)/);
1327
+ if (linkMatch) {
1328
+ result.push({ link: {
1329
+ href: linkMatch[2],
1330
+ content: linkMatch[1]
1331
+ } });
1332
+ remaining = remaining.slice(linkMatch[0].length);
1333
+ continue;
1334
+ }
1335
+ const imageMatch = remaining.match(/^!\[([^\]]*)\]\(([^)]+)\)/);
1336
+ if (imageMatch) {
1337
+ result.push({ __image: {
1338
+ src: imageMatch[2],
1339
+ alt: imageMatch[1]
1340
+ } });
1341
+ remaining = remaining.slice(imageMatch[0].length);
1342
+ continue;
1343
+ }
1344
+ const urlMatch = remaining.match(/^(https?:\/\/[^\s<>"\]]+)/);
1345
+ if (urlMatch) {
1346
+ result.push({ link: {
1347
+ href: urlMatch[1],
1348
+ content: urlMatch[1]
1349
+ } });
1350
+ remaining = remaining.slice(urlMatch[0].length);
1351
+ continue;
1352
+ }
1353
+ const plainMatch = remaining.match(/^[^*_`~[#~\n:/]+/);
1354
+ if (plainMatch) {
1355
+ result.push(plainMatch[0]);
1356
+ remaining = remaining.slice(plainMatch[0].length);
1357
+ continue;
1358
+ }
1359
+ result.push(remaining[0]);
1360
+ remaining = remaining.slice(1);
1361
+ }
1362
+ return mergeAdjacentStrings(result);
1363
+ }
1364
+ /**
1365
+ * Merge adjacent string elements in an inline array
1366
+ */
1367
+ function mergeAdjacentStrings(inlines) {
1368
+ const result = [];
1369
+ for (const item of inlines) if (typeof item === "string" && typeof result[result.length - 1] === "string") result[result.length - 1] = result[result.length - 1] + item;
1370
+ else result.push(item);
1371
+ return result;
1372
+ }
1373
+ /**
1374
+ * Create an image block
1375
+ */
1376
+ function createImageBlock(src, alt = "", height = 0, width = 0) {
1377
+ return { block: { image: {
1378
+ src,
1379
+ height,
1380
+ width,
1381
+ alt
1382
+ } } };
1383
+ }
1384
+ /**
1385
+ * Check if URL looks like an image
1386
+ */
1387
+ function isImageUrl(url) {
1388
+ return /\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)(\?.*)?$/i.test(url);
1389
+ }
1390
+ /**
1391
+ * Process inlines and extract any image markers into blocks
1392
+ */
1393
+ function processInlinesForImages(inlines) {
1394
+ const cleanInlines = [];
1395
+ const imageBlocks = [];
1396
+ for (const inline of inlines) if (typeof inline === "object" && "__image" in inline) {
1397
+ const img = inline.__image;
1398
+ imageBlocks.push(createImageBlock(img.src, img.alt));
1399
+ } else cleanInlines.push(inline);
1400
+ return {
1401
+ inlines: cleanInlines,
1402
+ imageBlocks
1403
+ };
1404
+ }
1405
+ /**
1406
+ * Convert markdown text to Tlon story format
1407
+ */
1408
+ function markdownToStory(markdown) {
1409
+ const story = [];
1410
+ const lines = markdown.split("\n");
1411
+ let i = 0;
1412
+ while (i < lines.length) {
1413
+ const line = lines[i];
1414
+ if (line.startsWith("```")) {
1415
+ const lang = line.slice(3).trim() || "plaintext";
1416
+ const codeLines = [];
1417
+ i++;
1418
+ while (i < lines.length && !lines[i].startsWith("```")) {
1419
+ codeLines.push(lines[i]);
1420
+ i++;
1421
+ }
1422
+ story.push({ block: { code: {
1423
+ code: codeLines.join("\n"),
1424
+ lang
1425
+ } } });
1426
+ i++;
1427
+ continue;
1428
+ }
1429
+ const headerMatch = line.match(/^(#{1,6})\s+(.+)$/);
1430
+ if (headerMatch) {
1431
+ const tag = `h${headerMatch[1].length}`;
1432
+ story.push({ block: { header: {
1433
+ tag,
1434
+ content: parseInlineMarkdown(headerMatch[2])
1435
+ } } });
1436
+ i++;
1437
+ continue;
1438
+ }
1439
+ if (/^(-{3,}|\*{3,})$/.test(line.trim())) {
1440
+ story.push({ block: { rule: null } });
1441
+ i++;
1442
+ continue;
1443
+ }
1444
+ if (line.startsWith("> ")) {
1445
+ const quoteLines = [];
1446
+ while (i < lines.length && lines[i].startsWith("> ")) {
1447
+ quoteLines.push(lines[i].slice(2));
1448
+ i++;
1449
+ }
1450
+ const quoteText = quoteLines.join("\n");
1451
+ story.push({ inline: [{ blockquote: parseInlineMarkdown(quoteText) }] });
1452
+ continue;
1453
+ }
1454
+ if (line.trim() === "") {
1455
+ i++;
1456
+ continue;
1457
+ }
1458
+ const paragraphLines = [];
1459
+ while (i < lines.length && lines[i].trim() !== "" && !lines[i].startsWith("#") && !lines[i].startsWith("```") && !lines[i].startsWith("> ") && !/^(-{3,}|\*{3,})$/.test(lines[i].trim())) {
1460
+ paragraphLines.push(lines[i]);
1461
+ i++;
1462
+ }
1463
+ if (paragraphLines.length > 0) {
1464
+ const inlines = parseInlineMarkdown(paragraphLines.join("\n"));
1465
+ const withBreaks = [];
1466
+ for (const inline of inlines) if (typeof inline === "string" && inline.includes("\n")) {
1467
+ const parts = inline.split("\n");
1468
+ for (let j = 0; j < parts.length; j++) {
1469
+ if (parts[j]) withBreaks.push(parts[j]);
1470
+ if (j < parts.length - 1) withBreaks.push({ break: null });
1471
+ }
1472
+ } else withBreaks.push(inline);
1473
+ const { inlines: cleanInlines, imageBlocks } = processInlinesForImages(withBreaks);
1474
+ if (cleanInlines.length > 0) story.push({ inline: cleanInlines });
1475
+ story.push(...imageBlocks);
1476
+ }
1477
+ }
1478
+ return story;
1479
+ }
1480
+ //#endregion
1481
+ //#region extensions/tlon/src/urbit/send.ts
1482
+ async function sendDm({ api, fromShip, toShip, text }) {
1483
+ return sendDmWithStory({
1484
+ api,
1485
+ fromShip,
1486
+ toShip,
1487
+ story: markdownToStory(text)
1488
+ });
1489
+ }
1490
+ async function sendDmWithStory({ api, fromShip, toShip, story }) {
1491
+ const sentAt = Date.now();
1492
+ const id = `${fromShip}/${(0, import_dist.scot)("ud", import_dist.da.fromUnix(sentAt))}`;
1493
+ const action = {
1494
+ ship: toShip,
1495
+ diff: {
1496
+ id,
1497
+ delta: { add: {
1498
+ memo: {
1499
+ content: story,
1500
+ author: fromShip,
1501
+ sent: sentAt
1502
+ },
1503
+ kind: null,
1504
+ time: null
1505
+ } }
1506
+ }
1507
+ };
1508
+ await api.poke({
1509
+ app: "chat",
1510
+ mark: "chat-dm-action",
1511
+ json: action
1512
+ });
1513
+ return {
1514
+ channel: "tlon",
1515
+ messageId: id
1516
+ };
1517
+ }
1518
+ async function sendGroupMessage({ api, fromShip, hostShip, channelName, text, replyToId }) {
1519
+ return sendGroupMessageWithStory({
1520
+ api,
1521
+ fromShip,
1522
+ hostShip,
1523
+ channelName,
1524
+ story: markdownToStory(text),
1525
+ replyToId
1526
+ });
1527
+ }
1528
+ async function sendGroupMessageWithStory({ api, fromShip, hostShip, channelName, story, replyToId }) {
1529
+ const sentAt = Date.now();
1530
+ let formattedReplyId = replyToId;
1531
+ if (replyToId && /^\d+$/.test(replyToId)) try {
1532
+ formattedReplyId = (0, import_dist.scot)("ud", BigInt(replyToId));
1533
+ } catch {}
1534
+ const action = { channel: {
1535
+ nest: `chat/${hostShip}/${channelName}`,
1536
+ action: formattedReplyId ? { post: { reply: {
1537
+ id: formattedReplyId,
1538
+ action: { add: {
1539
+ content: story,
1540
+ author: fromShip,
1541
+ sent: sentAt
1542
+ } }
1543
+ } } } : { post: { add: {
1544
+ content: story,
1545
+ author: fromShip,
1546
+ sent: sentAt,
1547
+ kind: "/chat",
1548
+ blob: null,
1549
+ meta: null
1550
+ } } }
1551
+ } };
1552
+ await api.poke({
1553
+ app: "channels",
1554
+ mark: "channel-action-1",
1555
+ json: action
1556
+ });
1557
+ return {
1558
+ channel: "tlon",
1559
+ messageId: `${fromShip}/${sentAt}`
1560
+ };
1561
+ }
1562
+ /**
1563
+ * Build a story with text and optional media (image)
1564
+ */
1565
+ function buildMediaStory(text, mediaUrl) {
1566
+ const story = [];
1567
+ const cleanText = text?.trim() ?? "";
1568
+ const cleanUrl = mediaUrl?.trim() ?? "";
1569
+ if (cleanText) story.push(...markdownToStory(cleanText));
1570
+ if (cleanUrl && isImageUrl(cleanUrl)) story.push(createImageBlock(cleanUrl, ""));
1571
+ else if (cleanUrl) story.push({ inline: [{ link: {
1572
+ href: cleanUrl,
1573
+ content: cleanUrl
1574
+ } }] });
1575
+ return story.length > 0 ? story : [{ inline: [""] }];
1576
+ }
1577
+ //#endregion
1578
+ //#region extensions/tlon/src/urbit/channel-ops.ts
1579
+ async function putUrbitChannel(deps, params) {
1580
+ return await urbitFetch({
1581
+ baseUrl: deps.baseUrl,
1582
+ path: `/~/channel/${deps.channelId}`,
1583
+ init: {
1584
+ method: "PUT",
1585
+ headers: {
1586
+ "Content-Type": "application/json",
1587
+ Cookie: deps.cookie
1588
+ },
1589
+ body: JSON.stringify(params.body)
1590
+ },
1591
+ ssrfPolicy: deps.ssrfPolicy,
1592
+ lookupFn: deps.lookupFn,
1593
+ fetchImpl: deps.fetchImpl,
1594
+ timeoutMs: 3e4,
1595
+ auditContext: params.auditContext
1596
+ });
1597
+ }
1598
+ async function pokeUrbitChannel(deps, params) {
1599
+ const pokeId = Date.now();
1600
+ const { response, release } = await putUrbitChannel(deps, {
1601
+ body: [{
1602
+ id: pokeId,
1603
+ action: "poke",
1604
+ ship: deps.ship,
1605
+ app: params.app,
1606
+ mark: params.mark,
1607
+ json: params.json
1608
+ }],
1609
+ auditContext: params.auditContext
1610
+ });
1611
+ try {
1612
+ if (!response.ok && response.status !== 204) {
1613
+ const errorText = await response.text().catch(() => "");
1614
+ throw new Error(`Poke failed: ${response.status}${errorText ? ` - ${errorText}` : ""}`);
1615
+ }
1616
+ return pokeId;
1617
+ } finally {
1618
+ await release();
1619
+ }
1620
+ }
1621
+ async function scryUrbitPath(deps, params) {
1622
+ const scryPath = `/~/scry${params.path}`;
1623
+ const { response, release } = await urbitFetch({
1624
+ baseUrl: deps.baseUrl,
1625
+ path: scryPath,
1626
+ init: {
1627
+ method: "GET",
1628
+ headers: { Cookie: deps.cookie }
1629
+ },
1630
+ ssrfPolicy: deps.ssrfPolicy,
1631
+ lookupFn: deps.lookupFn,
1632
+ fetchImpl: deps.fetchImpl,
1633
+ timeoutMs: 3e4,
1634
+ auditContext: params.auditContext
1635
+ });
1636
+ try {
1637
+ if (!response.ok) throw new Error(`Scry failed: ${response.status} for path ${params.path}`);
1638
+ return await response.json();
1639
+ } finally {
1640
+ await release();
1641
+ }
1642
+ }
1643
+ async function createUrbitChannel(deps, params) {
1644
+ const { response, release } = await putUrbitChannel(deps, params);
1645
+ try {
1646
+ if (!response.ok && response.status !== 204) throw new UrbitHttpError({
1647
+ operation: "Channel creation",
1648
+ status: response.status
1649
+ });
1650
+ } finally {
1651
+ await release();
1652
+ }
1653
+ }
1654
+ async function wakeUrbitChannel(deps) {
1655
+ const { response, release } = await putUrbitChannel(deps, {
1656
+ body: [{
1657
+ id: Date.now(),
1658
+ action: "poke",
1659
+ ship: deps.ship,
1660
+ app: "hood",
1661
+ mark: "helm-hi",
1662
+ json: "Opening API channel"
1663
+ }],
1664
+ auditContext: "tlon-urbit-channel-wake"
1665
+ });
1666
+ try {
1667
+ if (!response.ok && response.status !== 204) throw new UrbitHttpError({
1668
+ operation: "Channel activation",
1669
+ status: response.status
1670
+ });
1671
+ } finally {
1672
+ await release();
1673
+ }
1674
+ }
1675
+ async function ensureUrbitChannelOpen(deps, params) {
1676
+ await createUrbitChannel(deps, {
1677
+ body: params.createBody,
1678
+ auditContext: params.createAuditContext
1679
+ });
1680
+ await wakeUrbitChannel(deps);
1681
+ }
1682
+ //#endregion
1683
+ //#region extensions/tlon/src/urbit/sse-client.ts
1684
+ var UrbitSSEClient = class {
1685
+ constructor(url, cookie, options = {}) {
1686
+ this.subscriptions = [];
1687
+ this.eventHandlers = /* @__PURE__ */ new Map();
1688
+ this.aborted = false;
1689
+ this.streamController = null;
1690
+ this.reconnectAttempts = 0;
1691
+ this.isConnected = false;
1692
+ this.streamRelease = null;
1693
+ this.lastHeardEventId = -1;
1694
+ this.lastAcknowledgedEventId = -1;
1695
+ this.ackThreshold = 20;
1696
+ const ctx = getUrbitContext(url, options.ship);
1697
+ this.url = ctx.baseUrl;
1698
+ this.cookie = normalizeUrbitCookie(cookie);
1699
+ this.ship = ctx.ship;
1700
+ this.channelId = `${Math.floor(Date.now() / 1e3)}-${randomUUID()}`;
1701
+ this.channelUrl = new URL(`/~/channel/${this.channelId}`, this.url).toString();
1702
+ this.onReconnect = options.onReconnect ?? null;
1703
+ this.autoReconnect = options.autoReconnect !== false;
1704
+ this.maxReconnectAttempts = options.maxReconnectAttempts ?? 10;
1705
+ this.reconnectDelay = options.reconnectDelay ?? 1e3;
1706
+ this.maxReconnectDelay = options.maxReconnectDelay ?? 3e4;
1707
+ this.logger = options.logger ?? {};
1708
+ this.ssrfPolicy = options.ssrfPolicy;
1709
+ this.lookupFn = options.lookupFn;
1710
+ this.fetchImpl = options.fetchImpl;
1711
+ }
1712
+ async subscribe(params) {
1713
+ const subId = this.subscriptions.length + 1;
1714
+ const subscription = {
1715
+ id: subId,
1716
+ action: "subscribe",
1717
+ ship: this.ship,
1718
+ app: params.app,
1719
+ path: params.path
1720
+ };
1721
+ this.subscriptions.push(subscription);
1722
+ this.eventHandlers.set(subId, {
1723
+ event: params.event,
1724
+ err: params.err,
1725
+ quit: params.quit
1726
+ });
1727
+ if (this.isConnected) try {
1728
+ await this.sendSubscription(subscription);
1729
+ } catch (error) {
1730
+ this.eventHandlers.get(subId)?.err?.(error);
1731
+ }
1732
+ return subId;
1733
+ }
1734
+ async sendSubscription(subscription) {
1735
+ const { response, release } = await this.putChannelPayload([subscription], {
1736
+ timeoutMs: 3e4,
1737
+ auditContext: "tlon-urbit-subscribe"
1738
+ });
1739
+ try {
1740
+ if (!response.ok && response.status !== 204) {
1741
+ const errorText = await response.text().catch(() => "");
1742
+ throw new Error(`Subscribe failed: ${response.status}${errorText ? ` - ${errorText}` : ""}`);
1743
+ }
1744
+ } finally {
1745
+ await release();
1746
+ }
1747
+ }
1748
+ async connect() {
1749
+ await ensureUrbitChannelOpen({
1750
+ baseUrl: this.url,
1751
+ cookie: this.cookie,
1752
+ ship: this.ship,
1753
+ channelId: this.channelId,
1754
+ ssrfPolicy: this.ssrfPolicy,
1755
+ lookupFn: this.lookupFn,
1756
+ fetchImpl: this.fetchImpl
1757
+ }, {
1758
+ createBody: this.subscriptions,
1759
+ createAuditContext: "tlon-urbit-channel-create"
1760
+ });
1761
+ await this.openStream();
1762
+ this.isConnected = true;
1763
+ this.reconnectAttempts = 0;
1764
+ }
1765
+ async openStream() {
1766
+ const controller = new AbortController();
1767
+ const timeoutId = setTimeout(() => controller.abort(), 6e4);
1768
+ this.streamController = controller;
1769
+ const { response, release } = await urbitFetch({
1770
+ baseUrl: this.url,
1771
+ path: `/~/channel/${this.channelId}`,
1772
+ init: {
1773
+ method: "GET",
1774
+ headers: {
1775
+ Accept: "text/event-stream",
1776
+ Cookie: this.cookie
1777
+ }
1778
+ },
1779
+ ssrfPolicy: this.ssrfPolicy,
1780
+ lookupFn: this.lookupFn,
1781
+ fetchImpl: this.fetchImpl,
1782
+ signal: controller.signal,
1783
+ auditContext: "tlon-urbit-sse-stream"
1784
+ });
1785
+ this.streamRelease = release;
1786
+ clearTimeout(timeoutId);
1787
+ if (!response.ok) {
1788
+ await release();
1789
+ this.streamRelease = null;
1790
+ throw new Error(`Stream connection failed: ${response.status}`);
1791
+ }
1792
+ this.processStream(response.body).catch((error) => {
1793
+ if (!this.aborted) {
1794
+ this.logger.error?.(`Stream error: ${String(error)}`);
1795
+ for (const { err } of this.eventHandlers.values()) if (err) err(error);
1796
+ }
1797
+ });
1798
+ }
1799
+ async processStream(body) {
1800
+ if (!body) return;
1801
+ const stream = body instanceof ReadableStream ? Readable.fromWeb(body) : body;
1802
+ let buffer = "";
1803
+ try {
1804
+ for await (const chunk of stream) {
1805
+ if (this.aborted) break;
1806
+ buffer += chunk.toString();
1807
+ let eventEnd;
1808
+ while ((eventEnd = buffer.indexOf("\n\n")) !== -1) {
1809
+ const eventData = buffer.substring(0, eventEnd);
1810
+ buffer = buffer.substring(eventEnd + 2);
1811
+ this.processEvent(eventData);
1812
+ }
1813
+ }
1814
+ } finally {
1815
+ if (this.streamRelease) {
1816
+ const release = this.streamRelease;
1817
+ this.streamRelease = null;
1818
+ await release();
1819
+ }
1820
+ this.streamController = null;
1821
+ if (!this.aborted && this.autoReconnect) {
1822
+ this.isConnected = false;
1823
+ this.logger.log?.("[SSE] Stream ended, attempting reconnection...");
1824
+ await this.attemptReconnect();
1825
+ }
1826
+ }
1827
+ }
1828
+ processEvent(eventData) {
1829
+ const lines = eventData.split("\n");
1830
+ let data = null;
1831
+ let eventId = null;
1832
+ for (const line of lines) {
1833
+ if (line.startsWith("id: ")) eventId = parseInt(line.substring(4), 10);
1834
+ if (line.startsWith("data: ")) data = line.substring(6);
1835
+ }
1836
+ if (!data) return;
1837
+ if (eventId !== null && !isNaN(eventId)) {
1838
+ if (eventId > this.lastHeardEventId) {
1839
+ this.lastHeardEventId = eventId;
1840
+ if (eventId - this.lastAcknowledgedEventId > this.ackThreshold) {
1841
+ this.logger.log?.(`[SSE] Acking event ${eventId} (last acked: ${this.lastAcknowledgedEventId})`);
1842
+ this.ack(eventId).catch((err) => {
1843
+ this.logger.error?.(`Failed to ack event ${eventId}: ${String(err)}`);
1844
+ });
1845
+ }
1846
+ }
1847
+ }
1848
+ try {
1849
+ const parsed = JSON.parse(data);
1850
+ if (parsed.response === "quit") {
1851
+ if (parsed.id) {
1852
+ const handlers = this.eventHandlers.get(parsed.id);
1853
+ if (handlers?.quit) handlers.quit();
1854
+ }
1855
+ return;
1856
+ }
1857
+ if (parsed.id && this.eventHandlers.has(parsed.id)) {
1858
+ const { event } = this.eventHandlers.get(parsed.id) ?? {};
1859
+ if (event && parsed.json) event(parsed.json);
1860
+ } else if (parsed.json) {
1861
+ for (const { event } of this.eventHandlers.values()) if (event) event(parsed.json);
1862
+ }
1863
+ } catch (error) {
1864
+ this.logger.error?.(`Error parsing SSE event: ${String(error)}`);
1865
+ }
1866
+ }
1867
+ async poke(params) {
1868
+ return await pokeUrbitChannel({
1869
+ baseUrl: this.url,
1870
+ cookie: this.cookie,
1871
+ ship: this.ship,
1872
+ channelId: this.channelId,
1873
+ ssrfPolicy: this.ssrfPolicy,
1874
+ lookupFn: this.lookupFn,
1875
+ fetchImpl: this.fetchImpl
1876
+ }, {
1877
+ ...params,
1878
+ auditContext: "tlon-urbit-poke"
1879
+ });
1880
+ }
1881
+ async scry(path) {
1882
+ return await scryUrbitPath({
1883
+ baseUrl: this.url,
1884
+ cookie: this.cookie,
1885
+ ssrfPolicy: this.ssrfPolicy,
1886
+ lookupFn: this.lookupFn,
1887
+ fetchImpl: this.fetchImpl
1888
+ }, {
1889
+ path,
1890
+ auditContext: "tlon-urbit-scry"
1891
+ });
1892
+ }
1893
+ /**
1894
+ * Update the cookie used for authentication.
1895
+ * Call this when re-authenticating after session expiry.
1896
+ */
1897
+ updateCookie(newCookie) {
1898
+ this.cookie = normalizeUrbitCookie(newCookie);
1899
+ }
1900
+ async ack(eventId) {
1901
+ this.lastAcknowledgedEventId = eventId;
1902
+ const ackData = {
1903
+ id: Date.now(),
1904
+ action: "ack",
1905
+ "event-id": eventId
1906
+ };
1907
+ const { response, release } = await this.putChannelPayload([ackData], {
1908
+ timeoutMs: 1e4,
1909
+ auditContext: "tlon-urbit-ack"
1910
+ });
1911
+ try {
1912
+ if (!response.ok) throw new Error(`Ack failed with status ${response.status}`);
1913
+ } finally {
1914
+ await release();
1915
+ }
1916
+ }
1917
+ async attemptReconnect() {
1918
+ if (this.aborted || !this.autoReconnect) {
1919
+ this.logger.log?.("[SSE] Reconnection aborted or disabled");
1920
+ return;
1921
+ }
1922
+ if (this.reconnectAttempts >= this.maxReconnectAttempts) {
1923
+ this.logger.log?.(`[SSE] Max reconnection attempts (${this.maxReconnectAttempts}) reached. Waiting 10s before resetting...`);
1924
+ const extendedBackoff = 1e4;
1925
+ await new Promise((resolve) => setTimeout(resolve, extendedBackoff));
1926
+ this.reconnectAttempts = 0;
1927
+ this.logger.log?.("[SSE] Reconnection attempts reset, resuming reconnection...");
1928
+ }
1929
+ this.reconnectAttempts += 1;
1930
+ const delay = Math.min(this.reconnectDelay * Math.pow(2, this.reconnectAttempts - 1), this.maxReconnectDelay);
1931
+ this.logger.log?.(`[SSE] Reconnection attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts} in ${delay}ms...`);
1932
+ await new Promise((resolve) => setTimeout(resolve, delay));
1933
+ try {
1934
+ this.channelId = `${Math.floor(Date.now() / 1e3)}-${randomUUID()}`;
1935
+ this.channelUrl = new URL(`/~/channel/${this.channelId}`, this.url).toString();
1936
+ if (this.onReconnect) await this.onReconnect(this);
1937
+ await this.connect();
1938
+ this.logger.log?.("[SSE] Reconnection successful!");
1939
+ } catch (error) {
1940
+ this.logger.error?.(`[SSE] Reconnection failed: ${String(error)}`);
1941
+ await this.attemptReconnect();
1942
+ }
1943
+ }
1944
+ async close() {
1945
+ this.aborted = true;
1946
+ this.isConnected = false;
1947
+ this.streamController?.abort();
1948
+ try {
1949
+ const unsubscribes = this.subscriptions.map((sub) => ({
1950
+ id: sub.id,
1951
+ action: "unsubscribe",
1952
+ subscription: sub.id
1953
+ }));
1954
+ {
1955
+ const { response, release } = await this.putChannelPayload(unsubscribes, {
1956
+ timeoutMs: 3e4,
1957
+ auditContext: "tlon-urbit-unsubscribe"
1958
+ });
1959
+ try {
1960
+ response.body?.cancel();
1961
+ } finally {
1962
+ await release();
1963
+ }
1964
+ }
1965
+ {
1966
+ const { response, release } = await urbitFetch({
1967
+ baseUrl: this.url,
1968
+ path: `/~/channel/${this.channelId}`,
1969
+ init: {
1970
+ method: "DELETE",
1971
+ headers: { Cookie: this.cookie }
1972
+ },
1973
+ ssrfPolicy: this.ssrfPolicy,
1974
+ lookupFn: this.lookupFn,
1975
+ fetchImpl: this.fetchImpl,
1976
+ timeoutMs: 3e4,
1977
+ auditContext: "tlon-urbit-channel-close"
1978
+ });
1979
+ try {
1980
+ response.body?.cancel();
1981
+ } finally {
1982
+ await release();
1983
+ }
1984
+ }
1985
+ } catch (error) {
1986
+ this.logger.error?.(`Error closing channel: ${String(error)}`);
1987
+ }
1988
+ if (this.streamRelease) {
1989
+ const release = this.streamRelease;
1990
+ this.streamRelease = null;
1991
+ await release();
1992
+ }
1993
+ }
1994
+ async putChannelPayload(payload, params) {
1995
+ return await urbitFetch({
1996
+ baseUrl: this.url,
1997
+ path: `/~/channel/${this.channelId}`,
1998
+ init: {
1999
+ method: "PUT",
2000
+ headers: {
2001
+ "Content-Type": "application/json",
2002
+ Cookie: this.cookie
2003
+ },
2004
+ body: JSON.stringify(payload)
2005
+ },
2006
+ ssrfPolicy: this.ssrfPolicy,
2007
+ lookupFn: this.lookupFn,
2008
+ fetchImpl: this.fetchImpl,
2009
+ timeoutMs: params.timeoutMs,
2010
+ auditContext: params.auditContext
2011
+ });
2012
+ }
2013
+ };
2014
+ //#endregion
2015
+ //#region extensions/tlon/src/monitor/approval.ts
2016
+ /**
2017
+ * Generate a unique approval ID in the format: {type}-{timestamp}-{shortHash}
2018
+ */
2019
+ function generateApprovalId(type) {
2020
+ return `${type}-${Date.now()}-${Math.random().toString(36).substring(2, 6)}`;
2021
+ }
2022
+ /**
2023
+ * Create a pending approval object.
2024
+ */
2025
+ function createPendingApproval(params) {
2026
+ return {
2027
+ id: generateApprovalId(params.type),
2028
+ type: params.type,
2029
+ requestingShip: params.requestingShip,
2030
+ channelNest: params.channelNest,
2031
+ groupFlag: params.groupFlag,
2032
+ messagePreview: params.messagePreview,
2033
+ originalMessage: params.originalMessage,
2034
+ timestamp: Date.now()
2035
+ };
2036
+ }
2037
+ /**
2038
+ * Truncate text to a maximum length with ellipsis.
2039
+ */
2040
+ function truncate(text, maxLength) {
2041
+ if (text.length <= maxLength) return text;
2042
+ return text.substring(0, maxLength - 3) + "...";
2043
+ }
2044
+ /**
2045
+ * Format a notification message for the owner about a pending approval.
2046
+ */
2047
+ function formatApprovalRequest(approval) {
2048
+ const preview = approval.messagePreview ? `\n"${truncate(approval.messagePreview, 100)}"` : "";
2049
+ switch (approval.type) {
2050
+ case "dm": return `New DM request from ${approval.requestingShip}:${preview}\n\nReply "approve", "deny", or "block" (ID: ${approval.id})`;
2051
+ case "channel": return `${approval.requestingShip} mentioned you in ${approval.channelNest}:${preview}\n\nReply "approve", "deny", or "block"\n(ID: ${approval.id})`;
2052
+ case "group": return `Group invite from ${approval.requestingShip} to join ${approval.groupFlag}\n\nReply "approve", "deny", or "block"\n(ID: ${approval.id})`;
2053
+ }
2054
+ }
2055
+ /**
2056
+ * Parse an owner's response to an approval request.
2057
+ * Supports formats:
2058
+ * - "approve" / "deny" / "block" (applies to most recent pending)
2059
+ * - "approve dm-1234567890-abc" / "deny dm-1234567890-abc" (specific ID)
2060
+ * - "block" permanently blocks the ship via Tlon's native blocking
2061
+ */
2062
+ function parseApprovalResponse(text) {
2063
+ const match = text.trim().toLowerCase().match(/^(approve|deny|block)(?:\s+(.+))?$/);
2064
+ if (!match) return null;
2065
+ return {
2066
+ action: match[1],
2067
+ id: match[2]?.trim()
2068
+ };
2069
+ }
2070
+ /**
2071
+ * Check if a message text looks like an approval response.
2072
+ * Used to determine if we should intercept the message before normal processing.
2073
+ */
2074
+ function isApprovalResponse(text) {
2075
+ const trimmed = text.trim().toLowerCase();
2076
+ return trimmed.startsWith("approve") || trimmed.startsWith("deny") || trimmed.startsWith("block");
2077
+ }
2078
+ /**
2079
+ * Find a pending approval by ID, or return the most recent if no ID specified.
2080
+ */
2081
+ function findPendingApproval(pendingApprovals, id) {
2082
+ if (id) return pendingApprovals.find((a) => a.id === id);
2083
+ return pendingApprovals[pendingApprovals.length - 1];
2084
+ }
2085
+ /**
2086
+ * Remove a pending approval from the list by ID.
2087
+ */
2088
+ function removePendingApproval(pendingApprovals, id) {
2089
+ return pendingApprovals.filter((a) => a.id !== id);
2090
+ }
2091
+ /**
2092
+ * Format a confirmation message after an approval action.
2093
+ */
2094
+ function formatApprovalConfirmation(approval, action) {
2095
+ if (action === "block") return `Blocked ${approval.requestingShip}. They will no longer be able to contact the bot.`;
2096
+ const actionText = action === "approve" ? "Approved" : "Denied";
2097
+ switch (approval.type) {
2098
+ case "dm":
2099
+ if (action === "approve") return `${actionText} DM access for ${approval.requestingShip}. They can now message the bot.`;
2100
+ return `${actionText} DM request from ${approval.requestingShip}.`;
2101
+ case "channel":
2102
+ if (action === "approve") return `${actionText} ${approval.requestingShip} for ${approval.channelNest}. They can now interact in this channel.`;
2103
+ return `${actionText} ${approval.requestingShip} for ${approval.channelNest}.`;
2104
+ case "group":
2105
+ if (action === "approve") return `${actionText} group invite from ${approval.requestingShip} to ${approval.groupFlag}. Joining group...`;
2106
+ return `${actionText} group invite from ${approval.requestingShip} to ${approval.groupFlag}.`;
2107
+ }
2108
+ }
2109
+ /**
2110
+ * Parse an admin command from owner message.
2111
+ * Supports:
2112
+ * - "unblock ~ship" - unblock a specific ship
2113
+ * - "blocked" - list all blocked ships
2114
+ * - "pending" - list all pending approvals
2115
+ */
2116
+ function parseAdminCommand(text) {
2117
+ const trimmed = text.trim().toLowerCase();
2118
+ if (trimmed === "blocked") return { type: "blocked" };
2119
+ if (trimmed === "pending") return { type: "pending" };
2120
+ const unblockMatch = trimmed.match(/^unblock\s+(~[\w-]+)$/);
2121
+ if (unblockMatch) return {
2122
+ type: "unblock",
2123
+ ship: unblockMatch[1]
2124
+ };
2125
+ return null;
2126
+ }
2127
+ /**
2128
+ * Check if a message text looks like an admin command.
2129
+ */
2130
+ function isAdminCommand(text) {
2131
+ return parseAdminCommand(text) !== null;
2132
+ }
2133
+ /**
2134
+ * Format the list of blocked ships for display to owner.
2135
+ */
2136
+ function formatBlockedList(ships) {
2137
+ if (ships.length === 0) return "No ships are currently blocked.";
2138
+ return `Blocked ships (${ships.length}):\n${ships.map((s) => `• ${s}`).join("\n")}`;
2139
+ }
2140
+ /**
2141
+ * Format the list of pending approvals for display to owner.
2142
+ */
2143
+ function formatPendingList(approvals) {
2144
+ if (approvals.length === 0) return "No pending approval requests.";
2145
+ return `Pending approvals (${approvals.length}):\n${approvals.map((a) => `• ${a.id}: ${a.type} from ${a.requestingShip}`).join("\n")}`;
2146
+ }
2147
+ //#endregion
2148
+ //#region extensions/tlon/src/monitor/utils.ts
2149
+ function extractCites(content) {
2150
+ if (!content || !Array.isArray(content)) return [];
2151
+ const cites = [];
2152
+ for (const verse of content) if (verse?.block?.cite && typeof verse.block.cite === "object") {
2153
+ const cite = verse.block.cite;
2154
+ if (cite.chan && typeof cite.chan === "object") {
2155
+ const { nest, where } = cite.chan;
2156
+ const whereMatch = where?.match(/\/msg\/(~[a-z-]+)\/(.+)/);
2157
+ cites.push({
2158
+ type: "chan",
2159
+ nest,
2160
+ where,
2161
+ author: whereMatch?.[1],
2162
+ postId: whereMatch?.[2]
2163
+ });
2164
+ } else if (cite.group && typeof cite.group === "string") cites.push({
2165
+ type: "group",
2166
+ group: cite.group
2167
+ });
2168
+ else if (cite.desk && typeof cite.desk === "object") cites.push({
2169
+ type: "desk",
2170
+ flag: cite.desk.flag,
2171
+ where: cite.desk.where
2172
+ });
2173
+ else if (cite.bait && typeof cite.bait === "object") cites.push({
2174
+ type: "bait",
2175
+ group: cite.bait.group,
2176
+ nest: cite.bait.graph,
2177
+ where: cite.bait.where
2178
+ });
2179
+ }
2180
+ return cites;
2181
+ }
2182
+ function formatModelName(modelString) {
2183
+ if (!modelString) return "AI";
2184
+ const modelName = modelString.includes("/") ? modelString.split("/")[1] : modelString;
2185
+ const modelMappings = {
2186
+ "claude-opus-4-5": "Claude Opus 4.5",
2187
+ "claude-sonnet-4-5": "Claude Sonnet 4.5",
2188
+ "claude-sonnet-3-5": "Claude Sonnet 3.5",
2189
+ "gpt-4o": "GPT-4o",
2190
+ "gpt-4-turbo": "GPT-4 Turbo",
2191
+ "gpt-4": "GPT-4",
2192
+ "gemini-2.0-flash": "Gemini 2.0 Flash",
2193
+ "gemini-pro": "Gemini Pro"
2194
+ };
2195
+ if (modelMappings[modelName]) return modelMappings[modelName];
2196
+ return modelName.replace(/-/g, " ").split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
2197
+ }
2198
+ function isBotMentioned(messageText, botShipName, nickname) {
2199
+ if (!messageText || !botShipName) return false;
2200
+ if (/@all\b/i.test(messageText)) return true;
2201
+ const escapedShip = normalizeShip(botShipName).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2202
+ if (new RegExp(`(^|\\s)${escapedShip}(?=\\s|$)`, "i").test(messageText)) return true;
2203
+ if (nickname) {
2204
+ const escapedNickname = nickname.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2205
+ if (new RegExp(`(^|\\s)${escapedNickname}(?=\\s|$|[,!?.])`, "i").test(messageText)) return true;
2206
+ }
2207
+ return false;
2208
+ }
2209
+ /**
2210
+ * Strip bot ship mention from message text for command detection.
2211
+ * "~bot-ship /status" → "/status"
2212
+ */
2213
+ function stripBotMention(messageText, botShipName) {
2214
+ if (!messageText || !botShipName) return messageText;
2215
+ return messageText.replace(normalizeShip(botShipName), "").trim();
2216
+ }
2217
+ function isDmAllowed(senderShip, allowlist) {
2218
+ if (!allowlist || allowlist.length === 0) return false;
2219
+ const normalizedSender = normalizeShip(senderShip);
2220
+ return allowlist.map((ship) => normalizeShip(ship)).some((ship) => ship === normalizedSender);
2221
+ }
2222
+ function renderInlineItem(item, options) {
2223
+ if (typeof item === "string") return item;
2224
+ if (!item || typeof item !== "object") return "";
2225
+ if (item.ship) return item.ship;
2226
+ if ("sect" in item) return `@${item.sect || "all"}`;
2227
+ if (options?.allowBreak && item.break !== void 0) return "\n";
2228
+ if (item["inline-code"]) return `\`${item["inline-code"]}\``;
2229
+ if (item.code) return `\`${item.code}\``;
2230
+ if (item.link && item.link.href) return options?.linkMode === "href" ? item.link.href : item.link.content || item.link.href;
2231
+ if (item.bold && Array.isArray(item.bold)) return `**${extractInlineText(item.bold)}**`;
2232
+ if (item.italics && Array.isArray(item.italics)) return `*${extractInlineText(item.italics)}*`;
2233
+ if (item.strike && Array.isArray(item.strike)) return `~~${extractInlineText(item.strike)}~~`;
2234
+ if (options?.allowBlockquote && item.blockquote && Array.isArray(item.blockquote)) return `> ${extractInlineText(item.blockquote)}`;
2235
+ return "";
2236
+ }
2237
+ function extractInlineText(items) {
2238
+ return items.map((item) => renderInlineItem(item)).join("");
2239
+ }
2240
+ function extractMessageText(content) {
2241
+ if (!content || !Array.isArray(content)) return "";
2242
+ return content.map((verse) => {
2243
+ if (verse.inline && Array.isArray(verse.inline)) return verse.inline.map((item) => renderInlineItem(item, {
2244
+ linkMode: "href",
2245
+ allowBreak: true,
2246
+ allowBlockquote: true
2247
+ })).join("");
2248
+ if (verse.block && typeof verse.block === "object") {
2249
+ const block = verse.block;
2250
+ if (block.image && block.image.src) {
2251
+ const alt = block.image.alt ? ` (${block.image.alt})` : "";
2252
+ return `\n${block.image.src}${alt}\n`;
2253
+ }
2254
+ if (block.code && typeof block.code === "object") return `\n\`\`\`${block.code.lang || ""}\n${block.code.code || ""}\n\`\`\`\n`;
2255
+ if (block.header && typeof block.header === "object") return `\n## ${block.header.content?.map((item) => typeof item === "string" ? item : "").join("") || ""}\n`;
2256
+ if (block.cite && typeof block.cite === "object") {
2257
+ const cite = block.cite;
2258
+ if (cite.chan && typeof cite.chan === "object") {
2259
+ const { nest, where } = cite.chan;
2260
+ const whereMatch = where?.match(/\/msg\/(~[a-z-]+)\/(.+)/);
2261
+ if (whereMatch) {
2262
+ const [, author, _postId] = whereMatch;
2263
+ return `\n> [quoted: ${author} in ${nest}]\n`;
2264
+ }
2265
+ return `\n> [quoted from ${nest}]\n`;
2266
+ }
2267
+ if (cite.group && typeof cite.group === "string") return `\n> [ref: group ${cite.group}]\n`;
2268
+ if (cite.desk && typeof cite.desk === "object") return `\n> [ref: ${cite.desk.flag}]\n`;
2269
+ if (cite.bait && typeof cite.bait === "object") return `\n> [ref: ${cite.bait.graph} in ${cite.bait.group}]\n`;
2270
+ return `\n> [quoted message]\n`;
2271
+ }
2272
+ }
2273
+ return "";
2274
+ }).join("\n").trim();
2275
+ }
2276
+ function isSummarizationRequest(messageText) {
2277
+ return [
2278
+ /summarize\s+(this\s+)?(channel|chat|conversation)/i,
2279
+ /what\s+did\s+i\s+miss/i,
2280
+ /catch\s+me\s+up/i,
2281
+ /channel\s+summary/i,
2282
+ /tldr/i
2283
+ ].some((pattern) => pattern.test(messageText));
2284
+ }
2285
+ //#endregion
2286
+ //#region extensions/tlon/src/monitor/discovery.ts
2287
+ /**
2288
+ * Fetch groups-ui init data, returning channels and foreigns.
2289
+ * This is a single scry that provides both channel discovery and pending invites.
2290
+ */
2291
+ async function fetchInitData(api, runtime) {
2292
+ try {
2293
+ runtime.log?.("[tlon] Fetching groups-ui init data...");
2294
+ const initData = await api.scry("/groups-ui/v6/init.json");
2295
+ const channels = [];
2296
+ if (initData?.groups) {
2297
+ for (const groupData of Object.values(initData.groups)) if (groupData && typeof groupData === "object" && groupData.channels) {
2298
+ for (const channelNest of Object.keys(groupData.channels)) if (channelNest.startsWith("chat/")) channels.push(channelNest);
2299
+ }
2300
+ }
2301
+ if (channels.length > 0) runtime.log?.(`[tlon] Auto-discovered ${channels.length} chat channel(s)`);
2302
+ else runtime.log?.("[tlon] No chat channels found via auto-discovery");
2303
+ const foreigns = initData?.foreigns || null;
2304
+ if (foreigns) {
2305
+ const pendingCount = Object.values(foreigns).filter((f) => f.invites?.some((i) => i.valid)).length;
2306
+ if (pendingCount > 0) runtime.log?.(`[tlon] Found ${pendingCount} pending group invite(s)`);
2307
+ }
2308
+ return {
2309
+ channels,
2310
+ foreigns
2311
+ };
2312
+ } catch (error) {
2313
+ runtime.log?.(`[tlon] Init data fetch failed: ${error?.message ?? String(error)}`);
2314
+ return {
2315
+ channels: [],
2316
+ foreigns: null
2317
+ };
2318
+ }
2319
+ }
2320
+ async function fetchAllChannels(api, runtime) {
2321
+ const { channels } = await fetchInitData(api, runtime);
2322
+ return channels;
2323
+ }
2324
+ //#endregion
2325
+ //#region extensions/tlon/src/monitor/history.ts
2326
+ /**
2327
+ * Format a number as @ud (with dots every 3 digits from the right)
2328
+ * e.g., 170141184507799509469114119040828178432 -> 170.141.184.507.799.509.469.114.119.040.828.178.432
2329
+ */
2330
+ function formatUd(id) {
2331
+ const reversed = String(id).replace(/\./g, "").split("").toReversed();
2332
+ const chunks = [];
2333
+ for (let i = 0; i < reversed.length; i += 3) chunks.push(reversed.slice(i, i + 3).toReversed().join(""));
2334
+ return chunks.toReversed().join(".");
2335
+ }
2336
+ const messageCache = /* @__PURE__ */ new Map();
2337
+ const MAX_CACHED_MESSAGES = 100;
2338
+ function cacheMessage(channelNest, message) {
2339
+ if (!messageCache.has(channelNest)) messageCache.set(channelNest, []);
2340
+ const cache = messageCache.get(channelNest);
2341
+ if (!cache) return;
2342
+ cache.unshift(message);
2343
+ if (cache.length > MAX_CACHED_MESSAGES) cache.pop();
2344
+ }
2345
+ async function fetchChannelHistory(api, channelNest, count = 50, runtime) {
2346
+ try {
2347
+ const scryPath = `/channels/v4/${channelNest}/posts/newest/${count}/outline.json`;
2348
+ runtime?.log?.(`[tlon] Fetching history: ${scryPath}`);
2349
+ const data = await api.scry(scryPath);
2350
+ if (!data) return [];
2351
+ let posts = [];
2352
+ if (Array.isArray(data)) posts = data;
2353
+ else if (data.posts && typeof data.posts === "object") posts = Object.values(data.posts);
2354
+ else if (typeof data === "object") posts = Object.values(data);
2355
+ const messages = posts.map((item) => {
2356
+ const essay = item.essay || item["r-post"]?.set?.essay;
2357
+ const seal = item.seal || item["r-post"]?.set?.seal;
2358
+ return {
2359
+ author: essay?.author || "unknown",
2360
+ content: extractMessageText(essay?.content || []),
2361
+ timestamp: essay?.sent || Date.now(),
2362
+ id: seal?.id
2363
+ };
2364
+ }).filter((msg) => msg.content);
2365
+ runtime?.log?.(`[tlon] Extracted ${messages.length} messages from history`);
2366
+ return messages;
2367
+ } catch (error) {
2368
+ runtime?.log?.(`[tlon] Error fetching channel history: ${error?.message ?? String(error)}`);
2369
+ return [];
2370
+ }
2371
+ }
2372
+ async function getChannelHistory(api, channelNest, count = 50, runtime) {
2373
+ const cache = messageCache.get(channelNest) ?? [];
2374
+ if (cache.length >= count) {
2375
+ runtime?.log?.(`[tlon] Using cached messages (${cache.length} available)`);
2376
+ return cache.slice(0, count);
2377
+ }
2378
+ runtime?.log?.(`[tlon] Cache has ${cache.length} messages, need ${count}, fetching from scry...`);
2379
+ return await fetchChannelHistory(api, channelNest, count, runtime);
2380
+ }
2381
+ /**
2382
+ * Fetch thread/reply history for a specific parent post.
2383
+ * Used to get context when entering a thread conversation.
2384
+ */
2385
+ async function fetchThreadHistory(api, channelNest, parentId, count = 50, runtime) {
2386
+ try {
2387
+ const formattedParentId = formatUd(parentId);
2388
+ runtime?.log?.(`[tlon] Thread history - parentId: ${parentId} -> formatted: ${formattedParentId}`);
2389
+ const scryPath = `/channels/v4/${channelNest}/posts/post/id/${formattedParentId}/replies/newest/${count}.json`;
2390
+ runtime?.log?.(`[tlon] Fetching thread history: ${scryPath}`);
2391
+ const data = await api.scry(scryPath);
2392
+ if (!data) {
2393
+ runtime?.log?.(`[tlon] No thread history data returned`);
2394
+ return [];
2395
+ }
2396
+ let replies = [];
2397
+ if (Array.isArray(data)) replies = data;
2398
+ else if (data.replies && Array.isArray(data.replies)) replies = data.replies;
2399
+ else if (typeof data === "object") replies = Object.values(data);
2400
+ const messages = replies.map((item) => {
2401
+ const memo = item.memo || item["r-reply"]?.set?.memo || item;
2402
+ const seal = item.seal || item["r-reply"]?.set?.seal;
2403
+ return {
2404
+ author: memo?.author || "unknown",
2405
+ content: extractMessageText(memo?.content || []),
2406
+ timestamp: memo?.sent || Date.now(),
2407
+ id: seal?.id || item.id
2408
+ };
2409
+ }).filter((msg) => msg.content);
2410
+ runtime?.log?.(`[tlon] Extracted ${messages.length} thread replies from history`);
2411
+ return messages;
2412
+ } catch (error) {
2413
+ runtime?.log?.(`[tlon] Error fetching thread history: ${error?.message ?? String(error)}`);
2414
+ try {
2415
+ const altPath = `/channels/v4/${channelNest}/posts/post/id/${formatUd(parentId)}.json`;
2416
+ runtime?.log?.(`[tlon] Trying alternate path: ${altPath}`);
2417
+ const data = await api.scry(altPath);
2418
+ if (data?.seal?.meta?.replyCount > 0 && data?.replies) {
2419
+ const messages = (Array.isArray(data.replies) ? data.replies : Object.values(data.replies)).map((reply) => ({
2420
+ author: reply.memo?.author || "unknown",
2421
+ content: extractMessageText(reply.memo?.content || []),
2422
+ timestamp: reply.memo?.sent || Date.now(),
2423
+ id: reply.seal?.id
2424
+ })).filter((msg) => msg.content);
2425
+ runtime?.log?.(`[tlon] Extracted ${messages.length} replies from post data`);
2426
+ return messages;
2427
+ }
2428
+ } catch (altError) {
2429
+ runtime?.log?.(`[tlon] Alternate path also failed: ${altError?.message ?? String(altError)}`);
2430
+ }
2431
+ return [];
2432
+ }
2433
+ }
2434
+ //#endregion
2435
+ //#region extensions/tlon/src/monitor/media.ts
2436
+ const DEFAULT_MEDIA_DIR = path$1.join(homedir(), ".moldclaw", "workspace", "media", "inbound");
2437
+ /**
2438
+ * Extract image blocks from Tlon message content.
2439
+ * Returns array of image URLs found in the message.
2440
+ */
2441
+ function extractImageBlocks(content) {
2442
+ if (!content || !Array.isArray(content)) return [];
2443
+ const images = [];
2444
+ for (const verse of content) if (verse?.block?.image?.src) images.push({
2445
+ url: verse.block.image.src,
2446
+ alt: verse.block.image.alt
2447
+ });
2448
+ return images;
2449
+ }
2450
+ /**
2451
+ * Download a media file from URL to local storage.
2452
+ * Returns the local path where the file was saved.
2453
+ */
2454
+ async function downloadMedia(url, mediaDir = DEFAULT_MEDIA_DIR) {
2455
+ try {
2456
+ const parsedUrl = new URL(url);
2457
+ if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
2458
+ console.warn(`[tlon-media] Rejected non-http(s) URL: ${url}`);
2459
+ return null;
2460
+ }
2461
+ await mkdir(mediaDir, { recursive: true });
2462
+ const { response, release } = await fetchWithSsrFGuard({
2463
+ url,
2464
+ init: { method: "GET" },
2465
+ policy: /* @__PURE__ */ getDefaultSsrFPolicy(),
2466
+ auditContext: "tlon-media-download"
2467
+ });
2468
+ try {
2469
+ if (!response.ok) {
2470
+ console.error(`[tlon-media] Failed to fetch ${url}: ${response.status}`);
2471
+ return null;
2472
+ }
2473
+ const contentType = response.headers.get("content-type") || "application/octet-stream";
2474
+ const ext = getExtensionFromContentType(contentType) || getExtensionFromUrl(url) || "bin";
2475
+ const filename = `${randomUUID()}.${ext}`;
2476
+ const localPath = path$1.join(mediaDir, filename);
2477
+ const body = response.body;
2478
+ if (!body) {
2479
+ console.error(`[tlon-media] No response body for ${url}`);
2480
+ return null;
2481
+ }
2482
+ const writeStream = createWriteStream(localPath);
2483
+ await pipeline(Readable.fromWeb(body), writeStream);
2484
+ return {
2485
+ localPath,
2486
+ contentType,
2487
+ originalUrl: url
2488
+ };
2489
+ } finally {
2490
+ await release();
2491
+ }
2492
+ } catch (error) {
2493
+ console.error(`[tlon-media] Error downloading ${url}: ${error?.message ?? String(error)}`);
2494
+ return null;
2495
+ }
2496
+ }
2497
+ function getExtensionFromContentType(contentType) {
2498
+ return {
2499
+ "image/jpeg": "jpg",
2500
+ "image/jpg": "jpg",
2501
+ "image/png": "png",
2502
+ "image/gif": "gif",
2503
+ "image/webp": "webp",
2504
+ "image/svg+xml": "svg",
2505
+ "video/mp4": "mp4",
2506
+ "video/webm": "webm",
2507
+ "audio/mpeg": "mp3",
2508
+ "audio/ogg": "ogg"
2509
+ }[contentType.split(";")[0].trim()] ?? null;
2510
+ }
2511
+ function getExtensionFromUrl(url) {
2512
+ try {
2513
+ const match = new URL(url).pathname.match(/\.([a-z0-9]+)$/i);
2514
+ return match ? match[1].toLowerCase() : null;
2515
+ } catch {
2516
+ return null;
2517
+ }
2518
+ }
2519
+ /**
2520
+ * Download all images from a message and return attachment metadata.
2521
+ * Format matches MoldClaw's expected attachment structure.
2522
+ */
2523
+ async function downloadMessageImages(content, mediaDir) {
2524
+ const images = extractImageBlocks(content);
2525
+ if (images.length === 0) return [];
2526
+ const attachments = [];
2527
+ for (const image of images) {
2528
+ const downloaded = await downloadMedia(image.url, mediaDir);
2529
+ if (downloaded) attachments.push({
2530
+ path: downloaded.localPath,
2531
+ contentType: downloaded.contentType
2532
+ });
2533
+ }
2534
+ return attachments;
2535
+ }
2536
+ //#endregion
2537
+ //#region extensions/tlon/src/monitor/processed-messages.ts
2538
+ function createProcessedMessageTracker(limit = 2e3) {
2539
+ const dedupe = createDedupeCache({
2540
+ ttlMs: 0,
2541
+ maxSize: limit
2542
+ });
2543
+ const mark = (id) => {
2544
+ const trimmed = id?.trim();
2545
+ if (!trimmed) return true;
2546
+ return !dedupe.check(trimmed);
2547
+ };
2548
+ const has = (id) => {
2549
+ const trimmed = id?.trim();
2550
+ if (!trimmed) return false;
2551
+ return dedupe.peek(trimmed);
2552
+ };
2553
+ return {
2554
+ mark,
2555
+ has,
2556
+ size: () => dedupe.size()
2557
+ };
2558
+ }
2559
+ //#endregion
2560
+ //#region extensions/tlon/src/monitor/index.ts
2561
+ /**
2562
+ * Resolve channel authorization by merging file config with settings store.
2563
+ * Settings store takes precedence for fields it defines.
2564
+ */
2565
+ function resolveChannelAuthorization(cfg, channelNest, settings) {
2566
+ const tlonConfig = cfg.channels?.tlon;
2567
+ const fileRules = tlonConfig?.authorization?.channelRules ?? {};
2568
+ const rule = (settings?.channelRules ?? {})[channelNest] ?? fileRules[channelNest];
2569
+ const defaultShips = settings?.defaultAuthorizedShips ?? tlonConfig?.defaultAuthorizedShips ?? [];
2570
+ const allowedShips = rule?.allowedShips ?? defaultShips;
2571
+ return {
2572
+ mode: rule?.mode ?? "restricted",
2573
+ allowedShips
2574
+ };
2575
+ }
2576
+ async function monitorTlonProvider(opts = {}) {
2577
+ const core = getTlonRuntime();
2578
+ const cfg = core.config.loadConfig();
2579
+ if (cfg.channels?.tlon?.enabled === false) return;
2580
+ const logger = core.logging.getChildLogger({ module: "tlon-auto-reply" });
2581
+ const runtime = opts.runtime ?? createLoggerBackedRuntime({ logger });
2582
+ const account = resolveTlonAccount(cfg, opts.accountId ?? void 0);
2583
+ if (!account.enabled) return;
2584
+ if (!account.configured || !account.ship || !account.url || !account.code) throw new Error("Tlon account not configured (ship/url/code required)");
2585
+ const botShipName = normalizeShip(account.ship);
2586
+ runtime.log?.(`[tlon] Starting monitor for ${botShipName}`);
2587
+ const ssrfPolicy = ssrfPolicyFromAllowPrivateNetwork(account.allowPrivateNetwork);
2588
+ const accountUrl = account.url;
2589
+ const accountCode = account.code;
2590
+ async function authenticateWithRetry(maxAttempts = 10) {
2591
+ for (let attempt = 1;; attempt++) {
2592
+ if (opts.abortSignal?.aborted) throw new Error("Aborted while waiting to authenticate");
2593
+ try {
2594
+ runtime.log?.(`[tlon] Attempting authentication to ${accountUrl}...`);
2595
+ return await authenticate(accountUrl, accountCode, { ssrfPolicy });
2596
+ } catch (error) {
2597
+ runtime.error?.(`[tlon] Failed to authenticate (attempt ${attempt}): ${error?.message ?? String(error)}`);
2598
+ if (attempt >= maxAttempts) throw error;
2599
+ const delay = Math.min(3e4, 1e3 * Math.pow(2, attempt - 1));
2600
+ runtime.log?.(`[tlon] Retrying authentication in ${delay}ms...`);
2601
+ await new Promise((resolve, reject) => {
2602
+ const timer = setTimeout(resolve, delay);
2603
+ if (opts.abortSignal) {
2604
+ const onAbort = () => {
2605
+ clearTimeout(timer);
2606
+ reject(/* @__PURE__ */ new Error("Aborted"));
2607
+ };
2608
+ opts.abortSignal.addEventListener("abort", onAbort, { once: true });
2609
+ }
2610
+ });
2611
+ }
2612
+ }
2613
+ }
2614
+ let api = null;
2615
+ const cookie = await authenticateWithRetry();
2616
+ api = new UrbitSSEClient(account.url, cookie, {
2617
+ ship: botShipName,
2618
+ ssrfPolicy,
2619
+ logger: {
2620
+ log: (message) => runtime.log?.(message),
2621
+ error: (message) => runtime.error?.(message)
2622
+ },
2623
+ onReconnect: async (client) => {
2624
+ runtime.log?.("[tlon] Re-authenticating on SSE reconnect...");
2625
+ const newCookie = await authenticateWithRetry(5);
2626
+ client.updateCookie(newCookie);
2627
+ runtime.log?.("[tlon] Re-authentication successful");
2628
+ }
2629
+ });
2630
+ const processedTracker = createProcessedMessageTracker(2e3);
2631
+ let groupChannels = [];
2632
+ let botNickname = null;
2633
+ const settingsManager = createSettingsManager(api, {
2634
+ log: (msg) => runtime.log?.(msg),
2635
+ error: (msg) => runtime.error?.(msg)
2636
+ });
2637
+ let effectiveDmAllowlist = account.dmAllowlist;
2638
+ let effectiveShowModelSig = account.showModelSignature ?? false;
2639
+ let effectiveAutoAcceptDmInvites = account.autoAcceptDmInvites ?? false;
2640
+ let effectiveAutoAcceptGroupInvites = account.autoAcceptGroupInvites ?? false;
2641
+ let effectiveGroupInviteAllowlist = account.groupInviteAllowlist;
2642
+ let effectiveAutoDiscoverChannels = account.autoDiscoverChannels ?? false;
2643
+ let effectiveOwnerShip = account.ownerShip ? normalizeShip(account.ownerShip) : null;
2644
+ let pendingApprovals = [];
2645
+ let currentSettings = {};
2646
+ const participatedThreads = /* @__PURE__ */ new Set();
2647
+ const dmSendersBySession = /* @__PURE__ */ new Map();
2648
+ let sharedSessionWarningSent = false;
2649
+ try {
2650
+ const selfProfile = await api.scry("/contacts/v1/self.json");
2651
+ if (selfProfile && typeof selfProfile === "object") {
2652
+ botNickname = selfProfile.nickname?.value || null;
2653
+ if (botNickname) runtime.log?.(`[tlon] Bot nickname: ${botNickname}`);
2654
+ }
2655
+ } catch (error) {
2656
+ runtime.log?.(`[tlon] Could not fetch nickname: ${error?.message ?? String(error)}`);
2657
+ }
2658
+ let initForeigns = null;
2659
+ async function migrateConfigToSettings() {
2660
+ const migrations = [
2661
+ {
2662
+ key: "dmAllowlist",
2663
+ fileValue: account.dmAllowlist,
2664
+ settingsValue: currentSettings.dmAllowlist
2665
+ },
2666
+ {
2667
+ key: "groupInviteAllowlist",
2668
+ fileValue: account.groupInviteAllowlist,
2669
+ settingsValue: currentSettings.groupInviteAllowlist
2670
+ },
2671
+ {
2672
+ key: "groupChannels",
2673
+ fileValue: account.groupChannels,
2674
+ settingsValue: currentSettings.groupChannels
2675
+ },
2676
+ {
2677
+ key: "defaultAuthorizedShips",
2678
+ fileValue: account.defaultAuthorizedShips,
2679
+ settingsValue: currentSettings.defaultAuthorizedShips
2680
+ },
2681
+ {
2682
+ key: "autoDiscoverChannels",
2683
+ fileValue: account.autoDiscoverChannels,
2684
+ settingsValue: currentSettings.autoDiscoverChannels
2685
+ },
2686
+ {
2687
+ key: "autoAcceptDmInvites",
2688
+ fileValue: account.autoAcceptDmInvites,
2689
+ settingsValue: currentSettings.autoAcceptDmInvites
2690
+ },
2691
+ {
2692
+ key: "autoAcceptGroupInvites",
2693
+ fileValue: account.autoAcceptGroupInvites,
2694
+ settingsValue: currentSettings.autoAcceptGroupInvites
2695
+ },
2696
+ {
2697
+ key: "showModelSig",
2698
+ fileValue: account.showModelSignature,
2699
+ settingsValue: currentSettings.showModelSig
2700
+ }
2701
+ ];
2702
+ for (const { key, fileValue, settingsValue } of migrations) {
2703
+ const hasFileValue = Array.isArray(fileValue) ? fileValue.length > 0 : fileValue != null;
2704
+ const hasSettingsValue = Array.isArray(settingsValue) ? settingsValue.length > 0 : settingsValue != null;
2705
+ if (hasFileValue && !hasSettingsValue) try {
2706
+ await api.poke({
2707
+ app: "settings",
2708
+ mark: "settings-event",
2709
+ json: { "put-entry": {
2710
+ "bucket-key": "tlon",
2711
+ "entry-key": key,
2712
+ value: fileValue,
2713
+ desk: "moltbot"
2714
+ } }
2715
+ });
2716
+ runtime.log?.(`[tlon] Migrated ${key} from config to settings store`);
2717
+ } catch (err) {
2718
+ runtime.log?.(`[tlon] Failed to migrate ${key}: ${String(err)}`);
2719
+ }
2720
+ }
2721
+ }
2722
+ try {
2723
+ currentSettings = await settingsManager.load();
2724
+ await migrateConfigToSettings();
2725
+ if (currentSettings.defaultAuthorizedShips?.length) runtime.log?.(`[tlon] Using defaultAuthorizedShips from settings store: ${currentSettings.defaultAuthorizedShips.join(", ")}`);
2726
+ if (currentSettings.autoDiscoverChannels !== void 0) {
2727
+ effectiveAutoDiscoverChannels = currentSettings.autoDiscoverChannels;
2728
+ runtime.log?.(`[tlon] Using autoDiscoverChannels from settings store: ${effectiveAutoDiscoverChannels}`);
2729
+ }
2730
+ if (currentSettings.dmAllowlist !== void 0) {
2731
+ effectiveDmAllowlist = currentSettings.dmAllowlist;
2732
+ runtime.log?.(`[tlon] Using dmAllowlist from settings store: ${effectiveDmAllowlist.join(", ")}`);
2733
+ }
2734
+ if (currentSettings.showModelSig !== void 0) effectiveShowModelSig = currentSettings.showModelSig;
2735
+ if (currentSettings.autoAcceptDmInvites !== void 0) {
2736
+ effectiveAutoAcceptDmInvites = currentSettings.autoAcceptDmInvites;
2737
+ runtime.log?.(`[tlon] Using autoAcceptDmInvites from settings store: ${effectiveAutoAcceptDmInvites}`);
2738
+ }
2739
+ if (currentSettings.autoAcceptGroupInvites !== void 0) {
2740
+ effectiveAutoAcceptGroupInvites = currentSettings.autoAcceptGroupInvites;
2741
+ runtime.log?.(`[tlon] Using autoAcceptGroupInvites from settings store: ${effectiveAutoAcceptGroupInvites}`);
2742
+ }
2743
+ if (currentSettings.groupInviteAllowlist !== void 0) {
2744
+ effectiveGroupInviteAllowlist = currentSettings.groupInviteAllowlist;
2745
+ runtime.log?.(`[tlon] Using groupInviteAllowlist from settings store: ${effectiveGroupInviteAllowlist.join(", ")}`);
2746
+ }
2747
+ if (currentSettings.ownerShip) {
2748
+ effectiveOwnerShip = normalizeShip(currentSettings.ownerShip);
2749
+ runtime.log?.(`[tlon] Using ownerShip from settings store: ${effectiveOwnerShip}`);
2750
+ }
2751
+ if (currentSettings.pendingApprovals?.length) {
2752
+ pendingApprovals = currentSettings.pendingApprovals;
2753
+ runtime.log?.(`[tlon] Loaded ${pendingApprovals.length} pending approval(s) from settings`);
2754
+ }
2755
+ } catch (err) {
2756
+ runtime.log?.(`[tlon] Settings store not available, using file config: ${String(err)}`);
2757
+ }
2758
+ if (effectiveAutoDiscoverChannels) try {
2759
+ const initData = await fetchInitData(api, runtime);
2760
+ if (initData.channels.length > 0) groupChannels = initData.channels;
2761
+ initForeigns = initData.foreigns;
2762
+ } catch (error) {
2763
+ runtime.error?.(`[tlon] Auto-discovery failed: ${error?.message ?? String(error)}`);
2764
+ }
2765
+ if (account.groupChannels.length > 0) {
2766
+ for (const ch of account.groupChannels) if (!groupChannels.includes(ch)) groupChannels.push(ch);
2767
+ runtime.log?.(`[tlon] Added ${account.groupChannels.length} manual groupChannels to monitoring`);
2768
+ }
2769
+ if (currentSettings.groupChannels?.length) {
2770
+ for (const ch of currentSettings.groupChannels) if (!groupChannels.includes(ch)) groupChannels.push(ch);
2771
+ }
2772
+ if (groupChannels.length > 0) runtime.log?.(`[tlon] Monitoring ${groupChannels.length} group channel(s): ${groupChannels.join(", ")}`);
2773
+ else runtime.log?.("[tlon] No group channels to monitor (DMs only)");
2774
+ async function resolveCiteContent(cite) {
2775
+ if (cite.type !== "chan" || !cite.nest || !cite.postId) return null;
2776
+ try {
2777
+ const scryPath = `/channels/v4/${cite.nest}/posts/post/${cite.postId}.json`;
2778
+ runtime.log?.(`[tlon] Fetching cited post: ${scryPath}`);
2779
+ const data = await api.scry(scryPath);
2780
+ if (data?.essay?.content) return extractMessageText(data.essay.content) || null;
2781
+ return null;
2782
+ } catch (err) {
2783
+ runtime.log?.(`[tlon] Failed to fetch cited post: ${String(err)}`);
2784
+ return null;
2785
+ }
2786
+ }
2787
+ async function resolveAllCites(content) {
2788
+ const cites = extractCites(content);
2789
+ if (cites.length === 0) return "";
2790
+ const resolved = [];
2791
+ for (const cite of cites) {
2792
+ const text = await resolveCiteContent(cite);
2793
+ if (text) {
2794
+ const author = cite.author || "unknown";
2795
+ resolved.push(`> ${author} wrote: ${text}`);
2796
+ }
2797
+ }
2798
+ return resolved.length > 0 ? resolved.join("\n") + "\n\n" : "";
2799
+ }
2800
+ async function savePendingApprovals() {
2801
+ try {
2802
+ await api.poke({
2803
+ app: "settings",
2804
+ mark: "settings-event",
2805
+ json: { "put-entry": {
2806
+ desk: "moltbot",
2807
+ "bucket-key": "tlon",
2808
+ "entry-key": "pendingApprovals",
2809
+ value: JSON.stringify(pendingApprovals)
2810
+ } }
2811
+ });
2812
+ } catch (err) {
2813
+ runtime.error?.(`[tlon] Failed to save pending approvals: ${String(err)}`);
2814
+ }
2815
+ }
2816
+ async function addToDmAllowlist(ship) {
2817
+ const normalizedShip = normalizeShip(ship);
2818
+ if (!effectiveDmAllowlist.includes(normalizedShip)) effectiveDmAllowlist = [...effectiveDmAllowlist, normalizedShip];
2819
+ try {
2820
+ await api.poke({
2821
+ app: "settings",
2822
+ mark: "settings-event",
2823
+ json: { "put-entry": {
2824
+ desk: "moltbot",
2825
+ "bucket-key": "tlon",
2826
+ "entry-key": "dmAllowlist",
2827
+ value: effectiveDmAllowlist
2828
+ } }
2829
+ });
2830
+ runtime.log?.(`[tlon] Added ${normalizedShip} to dmAllowlist`);
2831
+ } catch (err) {
2832
+ runtime.error?.(`[tlon] Failed to update dmAllowlist: ${String(err)}`);
2833
+ }
2834
+ }
2835
+ async function addToChannelAllowlist(ship, channelNest) {
2836
+ const normalizedShip = normalizeShip(ship);
2837
+ const channelRules = currentSettings.channelRules ?? {};
2838
+ const rule = channelRules[channelNest] ?? {
2839
+ mode: "restricted",
2840
+ allowedShips: []
2841
+ };
2842
+ const allowedShips = [...rule.allowedShips ?? []];
2843
+ if (!allowedShips.includes(normalizedShip)) allowedShips.push(normalizedShip);
2844
+ const updatedRules = {
2845
+ ...channelRules,
2846
+ [channelNest]: {
2847
+ ...rule,
2848
+ allowedShips
2849
+ }
2850
+ };
2851
+ currentSettings = {
2852
+ ...currentSettings,
2853
+ channelRules: updatedRules
2854
+ };
2855
+ try {
2856
+ await api.poke({
2857
+ app: "settings",
2858
+ mark: "settings-event",
2859
+ json: { "put-entry": {
2860
+ desk: "moltbot",
2861
+ "bucket-key": "tlon",
2862
+ "entry-key": "channelRules",
2863
+ value: JSON.stringify(updatedRules)
2864
+ } }
2865
+ });
2866
+ runtime.log?.(`[tlon] Added ${normalizedShip} to ${channelNest} allowlist`);
2867
+ } catch (err) {
2868
+ runtime.error?.(`[tlon] Failed to update channelRules: ${String(err)}`);
2869
+ }
2870
+ }
2871
+ async function blockShip(ship) {
2872
+ const normalizedShip = normalizeShip(ship);
2873
+ try {
2874
+ await api.poke({
2875
+ app: "chat",
2876
+ mark: "chat-block-ship",
2877
+ json: { ship: normalizedShip }
2878
+ });
2879
+ runtime.log?.(`[tlon] Blocked ship ${normalizedShip}`);
2880
+ } catch (err) {
2881
+ runtime.error?.(`[tlon] Failed to block ship ${normalizedShip}: ${String(err)}`);
2882
+ }
2883
+ }
2884
+ async function isShipBlocked(ship) {
2885
+ const normalizedShip = normalizeShip(ship);
2886
+ try {
2887
+ const blocked = await api.scry("/chat/blocked.json");
2888
+ return Array.isArray(blocked) && blocked.some((s) => normalizeShip(s) === normalizedShip);
2889
+ } catch (err) {
2890
+ runtime.log?.(`[tlon] Failed to check blocked list: ${String(err)}`);
2891
+ return false;
2892
+ }
2893
+ }
2894
+ async function getBlockedShips() {
2895
+ try {
2896
+ const blocked = await api.scry("/chat/blocked.json");
2897
+ return Array.isArray(blocked) ? blocked : [];
2898
+ } catch (err) {
2899
+ runtime.log?.(`[tlon] Failed to get blocked list: ${String(err)}`);
2900
+ return [];
2901
+ }
2902
+ }
2903
+ async function unblockShip(ship) {
2904
+ const normalizedShip = normalizeShip(ship);
2905
+ try {
2906
+ await api.poke({
2907
+ app: "chat",
2908
+ mark: "chat-unblock-ship",
2909
+ json: { ship: normalizedShip }
2910
+ });
2911
+ runtime.log?.(`[tlon] Unblocked ship ${normalizedShip}`);
2912
+ return true;
2913
+ } catch (err) {
2914
+ runtime.error?.(`[tlon] Failed to unblock ship ${normalizedShip}: ${String(err)}`);
2915
+ return false;
2916
+ }
2917
+ }
2918
+ async function sendOwnerNotification(message) {
2919
+ if (!effectiveOwnerShip) {
2920
+ runtime.log?.("[tlon] No ownerShip configured, cannot send notification");
2921
+ return;
2922
+ }
2923
+ try {
2924
+ await sendDm({
2925
+ api,
2926
+ fromShip: botShipName,
2927
+ toShip: effectiveOwnerShip,
2928
+ text: message
2929
+ });
2930
+ runtime.log?.(`[tlon] Sent notification to owner ${effectiveOwnerShip}`);
2931
+ } catch (err) {
2932
+ runtime.error?.(`[tlon] Failed to send notification to owner: ${String(err)}`);
2933
+ }
2934
+ }
2935
+ async function queueApprovalRequest(approval) {
2936
+ if (await isShipBlocked(approval.requestingShip)) {
2937
+ runtime.log?.(`[tlon] Ignoring request from blocked ship ${approval.requestingShip}`);
2938
+ return;
2939
+ }
2940
+ const existingIndex = pendingApprovals.findIndex((a) => a.type === approval.type && a.requestingShip === approval.requestingShip && (approval.type !== "channel" || a.channelNest === approval.channelNest) && (approval.type !== "group" || a.groupFlag === approval.groupFlag));
2941
+ if (existingIndex !== -1) {
2942
+ const existing = pendingApprovals[existingIndex];
2943
+ if (approval.originalMessage) {
2944
+ existing.originalMessage = approval.originalMessage;
2945
+ existing.messagePreview = approval.messagePreview;
2946
+ }
2947
+ runtime.log?.(`[tlon] Updated existing approval for ${approval.requestingShip} (${approval.type}) - re-sending notification`);
2948
+ await savePendingApprovals();
2949
+ await sendOwnerNotification(formatApprovalRequest(existing));
2950
+ return;
2951
+ }
2952
+ pendingApprovals.push(approval);
2953
+ await savePendingApprovals();
2954
+ await sendOwnerNotification(formatApprovalRequest(approval));
2955
+ runtime.log?.(`[tlon] Queued approval request: ${approval.id} (${approval.type} from ${approval.requestingShip})`);
2956
+ }
2957
+ async function handleApprovalResponse(text) {
2958
+ const parsed = parseApprovalResponse(text);
2959
+ if (!parsed) return false;
2960
+ const approval = findPendingApproval(pendingApprovals, parsed.id);
2961
+ if (!approval) {
2962
+ await sendOwnerNotification("No pending approval found" + (parsed.id ? ` for ID: ${parsed.id}` : ""));
2963
+ return true;
2964
+ }
2965
+ if (parsed.action === "approve") {
2966
+ switch (approval.type) {
2967
+ case "dm":
2968
+ await addToDmAllowlist(approval.requestingShip);
2969
+ if (approval.originalMessage) {
2970
+ runtime.log?.(`[tlon] Processing original message from ${approval.requestingShip} after approval`);
2971
+ await processMessage({
2972
+ messageId: approval.originalMessage.messageId,
2973
+ senderShip: approval.requestingShip,
2974
+ messageText: approval.originalMessage.messageText,
2975
+ messageContent: approval.originalMessage.messageContent,
2976
+ isGroup: false,
2977
+ timestamp: approval.originalMessage.timestamp
2978
+ });
2979
+ }
2980
+ break;
2981
+ case "channel":
2982
+ if (approval.channelNest) {
2983
+ await addToChannelAllowlist(approval.requestingShip, approval.channelNest);
2984
+ if (approval.originalMessage) {
2985
+ const parsed = parseChannelNest(approval.channelNest);
2986
+ runtime.log?.(`[tlon] Processing original message from ${approval.requestingShip} in ${approval.channelNest} after approval`);
2987
+ await processMessage({
2988
+ messageId: approval.originalMessage.messageId,
2989
+ senderShip: approval.requestingShip,
2990
+ messageText: approval.originalMessage.messageText,
2991
+ messageContent: approval.originalMessage.messageContent,
2992
+ isGroup: true,
2993
+ channelNest: approval.channelNest,
2994
+ hostShip: parsed?.hostShip,
2995
+ channelName: parsed?.channelName,
2996
+ timestamp: approval.originalMessage.timestamp,
2997
+ parentId: approval.originalMessage.parentId,
2998
+ isThreadReply: approval.originalMessage.isThreadReply
2999
+ });
3000
+ }
3001
+ }
3002
+ break;
3003
+ case "group":
3004
+ if (approval.groupFlag) try {
3005
+ await api.poke({
3006
+ app: "groups",
3007
+ mark: "group-join",
3008
+ json: {
3009
+ flag: approval.groupFlag,
3010
+ "join-all": true
3011
+ }
3012
+ });
3013
+ runtime.log?.(`[tlon] Joined group ${approval.groupFlag} after approval`);
3014
+ setTimeout(async () => {
3015
+ try {
3016
+ const discoveredChannels = await fetchAllChannels(api, runtime);
3017
+ let newCount = 0;
3018
+ for (const channelNest of discoveredChannels) if (!watchedChannels.has(channelNest)) {
3019
+ watchedChannels.add(channelNest);
3020
+ newCount++;
3021
+ }
3022
+ if (newCount > 0) runtime.log?.(`[tlon] Discovered ${newCount} new channel(s) after joining group`);
3023
+ } catch (err) {
3024
+ runtime.log?.(`[tlon] Channel discovery after group join failed: ${String(err)}`);
3025
+ }
3026
+ }, 2e3);
3027
+ } catch (err) {
3028
+ runtime.error?.(`[tlon] Failed to join group ${approval.groupFlag}: ${String(err)}`);
3029
+ }
3030
+ break;
3031
+ }
3032
+ await sendOwnerNotification(formatApprovalConfirmation(approval, "approve"));
3033
+ } else if (parsed.action === "block") {
3034
+ await blockShip(approval.requestingShip);
3035
+ await sendOwnerNotification(formatApprovalConfirmation(approval, "block"));
3036
+ } else await sendOwnerNotification(formatApprovalConfirmation(approval, "deny"));
3037
+ pendingApprovals = removePendingApproval(pendingApprovals, approval.id);
3038
+ await savePendingApprovals();
3039
+ return true;
3040
+ }
3041
+ async function handleAdminCommand(text) {
3042
+ const command = parseAdminCommand(text);
3043
+ if (!command) return false;
3044
+ switch (command.type) {
3045
+ case "blocked": {
3046
+ const blockedShips = await getBlockedShips();
3047
+ await sendOwnerNotification(formatBlockedList(blockedShips));
3048
+ runtime.log?.(`[tlon] Owner requested blocked ships list (${blockedShips.length} ships)`);
3049
+ return true;
3050
+ }
3051
+ case "pending":
3052
+ await sendOwnerNotification(formatPendingList(pendingApprovals));
3053
+ runtime.log?.(`[tlon] Owner requested pending approvals list (${pendingApprovals.length} pending)`);
3054
+ return true;
3055
+ case "unblock": {
3056
+ const shipToUnblock = command.ship;
3057
+ if (!await isShipBlocked(shipToUnblock)) {
3058
+ await sendOwnerNotification(`${shipToUnblock} is not blocked.`);
3059
+ return true;
3060
+ }
3061
+ if (await unblockShip(shipToUnblock)) await sendOwnerNotification(`Unblocked ${shipToUnblock}.`);
3062
+ else await sendOwnerNotification(`Failed to unblock ${shipToUnblock}.`);
3063
+ return true;
3064
+ }
3065
+ }
3066
+ }
3067
+ function isOwner(ship) {
3068
+ if (!effectiveOwnerShip) return false;
3069
+ return normalizeShip(ship) === effectiveOwnerShip;
3070
+ }
3071
+ /**
3072
+ * Extract the DM partner ship from the 'whom' field.
3073
+ * This is the canonical source for DM routing (more reliable than essay.author).
3074
+ * Returns empty string if whom doesn't contain a valid patp-like value.
3075
+ */
3076
+ function extractDmPartnerShip(whom) {
3077
+ const normalized = normalizeShip(typeof whom === "string" ? whom : whom && typeof whom === "object" && "ship" in whom && typeof whom.ship === "string" ? whom.ship : "");
3078
+ return /^~?[a-z-]+$/i.test(normalized) ? normalized : "";
3079
+ }
3080
+ const processMessage = async (params) => {
3081
+ const { messageId, senderShip, isGroup, channelNest, hostShip, channelName, timestamp, parentId, isThreadReply, messageContent } = params;
3082
+ const groupChannel = channelNest;
3083
+ let messageText = params.messageText;
3084
+ let attachments = [];
3085
+ if (messageContent) try {
3086
+ attachments = await downloadMessageImages(messageContent);
3087
+ if (attachments.length > 0) runtime.log?.(`[tlon] Downloaded ${attachments.length} image(s) from message`);
3088
+ } catch (error) {
3089
+ runtime.log?.(`[tlon] Failed to download images: ${error?.message ?? String(error)}`);
3090
+ }
3091
+ if (isThreadReply && parentId && groupChannel) try {
3092
+ const threadHistory = await fetchThreadHistory(api, groupChannel, parentId, 20, runtime);
3093
+ if (threadHistory.length > 0) {
3094
+ const threadContext = threadHistory.slice(-10).map((msg) => `${msg.author}: ${msg.content}`).join("\n");
3095
+ messageText = `${`[Thread conversation - ${threadHistory.length} previous replies. You are participating in this thread. Only respond if relevant or helpful - you don't need to reply to every message.]`}\n\n[Previous messages]\n${threadContext}\n\n[Current message]\n${messageText}`;
3096
+ runtime?.log?.(`[tlon] Added thread context (${threadHistory.length} replies) to message`);
3097
+ }
3098
+ } catch (error) {
3099
+ runtime?.log?.(`[tlon] Could not fetch thread context: ${error?.message ?? String(error)}`);
3100
+ }
3101
+ if (isGroup && groupChannel && isSummarizationRequest(messageText)) try {
3102
+ const history = await getChannelHistory(api, groupChannel, 50, runtime);
3103
+ if (history.length === 0) {
3104
+ const noHistoryMsg = "I couldn't fetch any messages for this channel. It might be empty or there might be a permissions issue.";
3105
+ if (isGroup) {
3106
+ const parsed = parseChannelNest(groupChannel);
3107
+ if (parsed) await sendGroupMessage({
3108
+ api,
3109
+ fromShip: botShipName,
3110
+ hostShip: parsed.hostShip,
3111
+ channelName: parsed.channelName,
3112
+ text: noHistoryMsg
3113
+ });
3114
+ } else await sendDm({
3115
+ api,
3116
+ fromShip: botShipName,
3117
+ toShip: senderShip,
3118
+ text: noHistoryMsg
3119
+ });
3120
+ return;
3121
+ }
3122
+ const historyText = history.map((msg) => `[${new Date(msg.timestamp).toLocaleString()}] ${msg.author}: ${msg.content}`).join("\n");
3123
+ messageText = `Please summarize this channel conversation (${history.length} recent messages):\n\n${historyText}\n\nProvide a concise summary highlighting:
3124
+ 1. Main topics discussed
3125
+ 2. Key decisions or conclusions
3126
+ 3. Action items if any
3127
+ 4. Notable participants`;
3128
+ } catch (error) {
3129
+ const errorMsg = `Sorry, I encountered an error while fetching the channel history: ${error?.message ?? String(error)}`;
3130
+ if (isGroup && groupChannel) {
3131
+ const parsed = parseChannelNest(groupChannel);
3132
+ if (parsed) await sendGroupMessage({
3133
+ api,
3134
+ fromShip: botShipName,
3135
+ hostShip: parsed.hostShip,
3136
+ channelName: parsed.channelName,
3137
+ text: errorMsg
3138
+ });
3139
+ } else await sendDm({
3140
+ api,
3141
+ fromShip: botShipName,
3142
+ toShip: senderShip,
3143
+ text: errorMsg
3144
+ });
3145
+ return;
3146
+ }
3147
+ const route = core.channel.routing.resolveAgentRoute({
3148
+ cfg,
3149
+ channel: "tlon",
3150
+ accountId: opts.accountId ?? void 0,
3151
+ peer: {
3152
+ kind: isGroup ? "group" : "direct",
3153
+ id: isGroup ? groupChannel ?? senderShip : senderShip
3154
+ }
3155
+ });
3156
+ if (!isGroup) {
3157
+ const sessionKey = route.sessionKey;
3158
+ if (!dmSendersBySession.has(sessionKey)) dmSendersBySession.set(sessionKey, /* @__PURE__ */ new Set());
3159
+ const senders = dmSendersBySession.get(sessionKey);
3160
+ if (senders.size > 0 && !senders.has(senderShip)) {
3161
+ runtime.log?.("[tlon] ⚠️ SECURITY: Multiple users sharing DM session. Configure \"session.dmScope: per-channel-peer\" in MoldClaw config.");
3162
+ if (!sharedSessionWarningSent && effectiveOwnerShip) {
3163
+ sharedSessionWarningSent = true;
3164
+ sendDm({
3165
+ api,
3166
+ fromShip: botShipName,
3167
+ toShip: effectiveOwnerShip,
3168
+ text: "⚠️ Security Warning: Multiple users are sharing a DM session with this bot. This can leak conversation context between users.\n\nFix: Add to your MoldClaw config:\nsession:\n dmScope: \"per-channel-peer\"\n\nDocs: https://docs.moldclaw.ai/concepts/session#secure-dm-mode"
3169
+ }).catch((err) => runtime.error?.(`[tlon] Failed to send security warning to owner: ${err}`));
3170
+ }
3171
+ }
3172
+ senders.add(senderShip);
3173
+ }
3174
+ const senderRole = isOwner(senderShip) ? "owner" : "user";
3175
+ const fromLabel = isGroup ? `${senderShip} [${senderRole}] in ${channelNest}` : `${senderShip} [${senderRole}]`;
3176
+ const shouldComputeAuth = core.channel.commands.shouldComputeCommandAuthorized(messageText, cfg);
3177
+ let commandAuthorized = false;
3178
+ if (shouldComputeAuth) {
3179
+ const useAccessGroups = cfg.commands?.useAccessGroups !== false;
3180
+ const senderIsOwner = isOwner(senderShip);
3181
+ commandAuthorized = core.channel.commands.resolveCommandAuthorizedFromAuthorizers({
3182
+ useAccessGroups,
3183
+ authorizers: [{
3184
+ configured: Boolean(effectiveOwnerShip),
3185
+ allowed: senderIsOwner
3186
+ }]
3187
+ });
3188
+ if (!commandAuthorized) console.log(`[tlon] Command attempt denied: ${senderShip} is not owner (owner=${effectiveOwnerShip ?? "not configured"})`);
3189
+ }
3190
+ let bodyWithAttachments = messageText;
3191
+ if (attachments.length > 0) bodyWithAttachments = attachments.map((a) => `[media attached: ${a.path} (${a.contentType}) | ${a.path}]`).join("\n") + "\n" + messageText;
3192
+ const body = core.channel.reply.formatAgentEnvelope({
3193
+ channel: "Tlon",
3194
+ from: fromLabel,
3195
+ timestamp,
3196
+ body: bodyWithAttachments
3197
+ });
3198
+ const commandBody = isGroup ? stripBotMention(messageText, botShipName) : messageText;
3199
+ const ctxPayload = core.channel.reply.finalizeInboundContext({
3200
+ Body: body,
3201
+ RawBody: messageText,
3202
+ CommandBody: commandBody,
3203
+ From: isGroup ? `tlon:group:${groupChannel}` : `tlon:${senderShip}`,
3204
+ To: `tlon:${botShipName}`,
3205
+ SessionKey: route.sessionKey,
3206
+ AccountId: route.accountId,
3207
+ ChatType: isGroup ? "group" : "direct",
3208
+ ConversationLabel: fromLabel,
3209
+ SenderName: senderShip,
3210
+ SenderId: senderShip,
3211
+ SenderRole: senderRole,
3212
+ CommandAuthorized: commandAuthorized,
3213
+ CommandSource: "text",
3214
+ Provider: "tlon",
3215
+ Surface: "tlon",
3216
+ MessageSid: messageId,
3217
+ ...attachments.length > 0 && { Attachments: attachments },
3218
+ OriginatingChannel: "tlon",
3219
+ OriginatingTo: `tlon:${isGroup ? groupChannel : botShipName}`,
3220
+ ...parentId && {
3221
+ ThreadId: String(parentId),
3222
+ ReplyToId: String(parentId)
3223
+ }
3224
+ });
3225
+ const dispatchStartTime = Date.now();
3226
+ const responsePrefix = core.channel.reply.resolveEffectiveMessagesConfig(cfg, route.agentId).responsePrefix;
3227
+ const humanDelay = core.channel.reply.resolveHumanDelayConfig(cfg, route.agentId);
3228
+ await core.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
3229
+ ctx: ctxPayload,
3230
+ cfg,
3231
+ dispatcherOptions: {
3232
+ responsePrefix,
3233
+ humanDelay,
3234
+ deliver: async (payload) => {
3235
+ let replyText = payload.text;
3236
+ if (!replyText) return;
3237
+ if (effectiveShowModelSig) {
3238
+ const extPayload = payload;
3239
+ const extRoute = route;
3240
+ const defaultModel = cfg.agents?.defaults?.model;
3241
+ const modelInfo = extPayload.metadata?.model || extPayload.model || extRoute.model || (typeof defaultModel === "string" ? defaultModel : defaultModel?.primary);
3242
+ extPayload.metadata?.model || extPayload.model || extRoute.model || typeof defaultModel === "string" || defaultModel?.primary;
3243
+ replyText = `${replyText}\n\n_[Generated by ${formatModelName(modelInfo)}]_`;
3244
+ }
3245
+ if (isGroup && groupChannel) {
3246
+ const parsed = parseChannelNest(groupChannel);
3247
+ if (!parsed) return;
3248
+ await sendGroupMessage({
3249
+ api,
3250
+ fromShip: botShipName,
3251
+ hostShip: parsed.hostShip,
3252
+ channelName: parsed.channelName,
3253
+ text: replyText,
3254
+ replyToId: parentId ?? void 0
3255
+ });
3256
+ if (parentId) {
3257
+ participatedThreads.add(String(parentId));
3258
+ runtime.log?.(`[tlon] Now tracking thread for future replies: ${parentId}`);
3259
+ }
3260
+ } else await sendDm({
3261
+ api,
3262
+ fromShip: botShipName,
3263
+ toShip: senderShip,
3264
+ text: replyText
3265
+ });
3266
+ },
3267
+ onError: (err, info) => {
3268
+ const dispatchDuration = Date.now() - dispatchStartTime;
3269
+ runtime.error?.(`[tlon] ${info.kind} reply failed after ${dispatchDuration}ms: ${String(err)}`);
3270
+ }
3271
+ }
3272
+ });
3273
+ };
3274
+ const watchedChannels = new Set(groupChannels);
3275
+ const handleChannelsFirehose = async (event) => {
3276
+ try {
3277
+ const nest = event?.nest;
3278
+ if (!nest) return;
3279
+ if (!watchedChannels.has(nest)) return;
3280
+ const response = event?.response;
3281
+ if (!response) return;
3282
+ const essay = response?.post?.["r-post"]?.set?.essay;
3283
+ const memo = response?.post?.["r-post"]?.reply?.["r-reply"]?.set?.memo;
3284
+ if (!essay && !memo) return;
3285
+ const content = memo || essay;
3286
+ const isThreadReply = Boolean(memo);
3287
+ const messageId = isThreadReply ? response?.post?.["r-post"]?.reply?.id : response?.post?.id;
3288
+ if (!processedTracker.mark(messageId)) return;
3289
+ const senderShip = normalizeShip(content.author ?? "");
3290
+ if (!senderShip || senderShip === botShipName) return;
3291
+ const rawText = extractMessageText(content.content);
3292
+ if (!rawText.trim()) return;
3293
+ cacheMessage(nest, {
3294
+ author: senderShip,
3295
+ content: rawText,
3296
+ timestamp: content.sent || Date.now(),
3297
+ id: messageId
3298
+ });
3299
+ const seal = isThreadReply ? response?.post?.["r-post"]?.reply?.["r-reply"]?.set?.seal : response?.post?.["r-post"]?.set?.seal;
3300
+ const parentId = seal?.["parent-id"] || seal?.parent || null;
3301
+ const mentioned = isBotMentioned(rawText, botShipName, botNickname ?? void 0);
3302
+ const inParticipatedThread = isThreadReply && parentId && participatedThreads.has(String(parentId));
3303
+ if (!mentioned && !inParticipatedThread) return;
3304
+ if (inParticipatedThread && !mentioned) runtime.log?.(`[tlon] Responding to thread we participated in (no mention): ${parentId}`);
3305
+ if (isOwner(senderShip)) runtime.log?.(`[tlon] Owner ${senderShip} is always allowed in channels`);
3306
+ else {
3307
+ const { mode, allowedShips } = resolveChannelAuthorization(cfg, nest, currentSettings);
3308
+ if (mode === "restricted") {
3309
+ if (!allowedShips.map(normalizeShip).includes(senderShip)) {
3310
+ if (effectiveOwnerShip) await queueApprovalRequest(createPendingApproval({
3311
+ type: "channel",
3312
+ requestingShip: senderShip,
3313
+ channelNest: nest,
3314
+ messagePreview: rawText.substring(0, 100),
3315
+ originalMessage: {
3316
+ messageId: messageId ?? "",
3317
+ messageText: rawText,
3318
+ messageContent: content.content,
3319
+ timestamp: content.sent || Date.now(),
3320
+ parentId: parentId ?? void 0,
3321
+ isThreadReply
3322
+ }
3323
+ }));
3324
+ else runtime.log?.(`[tlon] Access denied: ${senderShip} in ${nest} (allowed: ${allowedShips.join(", ")})`);
3325
+ return;
3326
+ }
3327
+ }
3328
+ }
3329
+ const messageText = await resolveAllCites(content.content) + rawText;
3330
+ const parsed = parseChannelNest(nest);
3331
+ await processMessage({
3332
+ messageId: messageId ?? "",
3333
+ senderShip,
3334
+ messageText,
3335
+ messageContent: content.content,
3336
+ isGroup: true,
3337
+ channelNest: nest,
3338
+ hostShip: parsed?.hostShip,
3339
+ channelName: parsed?.channelName,
3340
+ timestamp: content.sent || Date.now(),
3341
+ parentId,
3342
+ isThreadReply
3343
+ });
3344
+ } catch (error) {
3345
+ runtime.error?.(`[tlon] Error handling channel firehose event: ${error?.message ?? String(error)}`);
3346
+ }
3347
+ };
3348
+ const processedDmInvites = /* @__PURE__ */ new Set();
3349
+ const handleChatFirehose = async (event) => {
3350
+ try {
3351
+ if (Array.isArray(event)) {
3352
+ for (const invite of event) {
3353
+ const ship = normalizeShip(invite.ship || "");
3354
+ if (!ship || processedDmInvites.has(ship)) continue;
3355
+ if (isOwner(ship)) {
3356
+ try {
3357
+ await api.poke({
3358
+ app: "chat",
3359
+ mark: "chat-dm-rsvp",
3360
+ json: {
3361
+ ship,
3362
+ ok: true
3363
+ }
3364
+ });
3365
+ processedDmInvites.add(ship);
3366
+ runtime.log?.(`[tlon] Auto-accepted DM invite from owner ${ship}`);
3367
+ } catch (err) {
3368
+ runtime.error?.(`[tlon] Failed to auto-accept DM from owner: ${String(err)}`);
3369
+ }
3370
+ continue;
3371
+ }
3372
+ if (effectiveAutoAcceptDmInvites && isDmAllowed(ship, effectiveDmAllowlist)) {
3373
+ try {
3374
+ await api.poke({
3375
+ app: "chat",
3376
+ mark: "chat-dm-rsvp",
3377
+ json: {
3378
+ ship,
3379
+ ok: true
3380
+ }
3381
+ });
3382
+ processedDmInvites.add(ship);
3383
+ runtime.log?.(`[tlon] Auto-accepted DM invite from ${ship}`);
3384
+ } catch (err) {
3385
+ runtime.error?.(`[tlon] Failed to auto-accept DM from ${ship}: ${String(err)}`);
3386
+ }
3387
+ continue;
3388
+ }
3389
+ if (effectiveOwnerShip && !isDmAllowed(ship, effectiveDmAllowlist)) {
3390
+ await queueApprovalRequest(createPendingApproval({
3391
+ type: "dm",
3392
+ requestingShip: ship,
3393
+ messagePreview: "(DM invite - no message yet)"
3394
+ }));
3395
+ processedDmInvites.add(ship);
3396
+ }
3397
+ }
3398
+ return;
3399
+ }
3400
+ if (!("whom" in event) || !("response" in event)) return;
3401
+ const whom = event.whom;
3402
+ const messageId = event.id;
3403
+ const essay = event.response?.add?.essay;
3404
+ if (!essay) return;
3405
+ if (!processedTracker.mark(messageId)) return;
3406
+ const authorShip = normalizeShip(essay.author ?? "");
3407
+ const partnerShip = extractDmPartnerShip(whom);
3408
+ const senderShip = partnerShip || authorShip;
3409
+ if (authorShip === botShipName) return;
3410
+ if (!senderShip || senderShip === botShipName) return;
3411
+ if (authorShip && partnerShip && authorShip !== partnerShip) runtime.log?.(`[tlon] DM ship mismatch (author=${authorShip}, partner=${partnerShip}) - routing to partner`);
3412
+ const rawText = extractMessageText(essay.content);
3413
+ if (!rawText.trim()) return;
3414
+ const resolvedMessageText = await resolveAllCites(essay.content) + rawText;
3415
+ const messageText = rawText;
3416
+ if (isOwner(senderShip) && isApprovalResponse(messageText)) {
3417
+ if (await handleApprovalResponse(messageText)) {
3418
+ runtime.log?.(`[tlon] Processed approval response from owner: ${messageText}`);
3419
+ return;
3420
+ }
3421
+ }
3422
+ if (isOwner(senderShip) && isAdminCommand(messageText)) {
3423
+ if (await handleAdminCommand(messageText)) {
3424
+ runtime.log?.(`[tlon] Processed admin command from owner: ${messageText}`);
3425
+ return;
3426
+ }
3427
+ }
3428
+ if (isOwner(senderShip)) {
3429
+ runtime.log?.(`[tlon] Processing DM from owner ${senderShip}`);
3430
+ await processMessage({
3431
+ messageId: messageId ?? "",
3432
+ senderShip,
3433
+ messageText: resolvedMessageText,
3434
+ messageContent: essay.content,
3435
+ isGroup: false,
3436
+ timestamp: essay.sent || Date.now()
3437
+ });
3438
+ return;
3439
+ }
3440
+ if (!isDmAllowed(senderShip, effectiveDmAllowlist)) {
3441
+ if (effectiveOwnerShip) await queueApprovalRequest(createPendingApproval({
3442
+ type: "dm",
3443
+ requestingShip: senderShip,
3444
+ messagePreview: messageText.substring(0, 100),
3445
+ originalMessage: {
3446
+ messageId: messageId ?? "",
3447
+ messageText,
3448
+ messageContent: essay.content,
3449
+ timestamp: essay.sent || Date.now()
3450
+ }
3451
+ }));
3452
+ else runtime.log?.(`[tlon] Blocked DM from ${senderShip}: not in allowlist`);
3453
+ return;
3454
+ }
3455
+ await processMessage({
3456
+ messageId: messageId ?? "",
3457
+ senderShip,
3458
+ messageText: resolvedMessageText,
3459
+ messageContent: essay.content,
3460
+ isGroup: false,
3461
+ timestamp: essay.sent || Date.now()
3462
+ });
3463
+ } catch (error) {
3464
+ runtime.error?.(`[tlon] Error handling chat firehose event: ${error?.message ?? String(error)}`);
3465
+ }
3466
+ };
3467
+ try {
3468
+ runtime.log?.("[tlon] Subscribing to firehose updates...");
3469
+ await api.subscribe({
3470
+ app: "channels",
3471
+ path: "/v2",
3472
+ event: handleChannelsFirehose,
3473
+ err: (error) => {
3474
+ runtime.error?.(`[tlon] Channels firehose error: ${String(error)}`);
3475
+ },
3476
+ quit: () => {
3477
+ runtime.log?.("[tlon] Channels firehose subscription ended");
3478
+ }
3479
+ });
3480
+ runtime.log?.("[tlon] Subscribed to channels firehose (/v2)");
3481
+ await api.subscribe({
3482
+ app: "chat",
3483
+ path: "/v3",
3484
+ event: handleChatFirehose,
3485
+ err: (error) => {
3486
+ runtime.error?.(`[tlon] Chat firehose error: ${String(error)}`);
3487
+ },
3488
+ quit: () => {
3489
+ runtime.log?.("[tlon] Chat firehose subscription ended");
3490
+ }
3491
+ });
3492
+ runtime.log?.("[tlon] Subscribed to chat firehose (/v3)");
3493
+ await api.subscribe({
3494
+ app: "contacts",
3495
+ path: "/v1/news",
3496
+ event: (event) => {
3497
+ try {
3498
+ if (event?.self) {
3499
+ const selfUpdate = event.self;
3500
+ if (selfUpdate?.contact?.nickname?.value !== void 0) {
3501
+ const newNickname = selfUpdate.contact.nickname.value || null;
3502
+ if (newNickname !== botNickname) {
3503
+ botNickname = newNickname;
3504
+ runtime.log?.(`[tlon] Nickname updated: ${botNickname}`);
3505
+ }
3506
+ }
3507
+ }
3508
+ } catch (error) {
3509
+ runtime.error?.(`[tlon] Error handling contacts event: ${error?.message ?? String(error)}`);
3510
+ }
3511
+ },
3512
+ err: (error) => {
3513
+ runtime.error?.(`[tlon] Contacts subscription error: ${String(error)}`);
3514
+ },
3515
+ quit: () => {
3516
+ runtime.log?.("[tlon] Contacts subscription ended");
3517
+ }
3518
+ });
3519
+ runtime.log?.("[tlon] Subscribed to contacts updates (/v1/news)");
3520
+ settingsManager.onChange((newSettings) => {
3521
+ currentSettings = newSettings;
3522
+ if (newSettings.groupChannels?.length) {
3523
+ const newChannels = newSettings.groupChannels;
3524
+ for (const ch of newChannels) if (!watchedChannels.has(ch)) {
3525
+ watchedChannels.add(ch);
3526
+ runtime.log?.(`[tlon] Settings: now watching channel ${ch}`);
3527
+ }
3528
+ }
3529
+ if (newSettings.dmAllowlist !== void 0) {
3530
+ effectiveDmAllowlist = newSettings.dmAllowlist;
3531
+ runtime.log?.(`[tlon] Settings: dmAllowlist updated to ${effectiveDmAllowlist.join(", ")}`);
3532
+ }
3533
+ if (newSettings.showModelSig !== void 0) {
3534
+ effectiveShowModelSig = newSettings.showModelSig;
3535
+ runtime.log?.(`[tlon] Settings: showModelSig = ${effectiveShowModelSig}`);
3536
+ }
3537
+ if (newSettings.autoAcceptDmInvites !== void 0) {
3538
+ effectiveAutoAcceptDmInvites = newSettings.autoAcceptDmInvites;
3539
+ runtime.log?.(`[tlon] Settings: autoAcceptDmInvites = ${effectiveAutoAcceptDmInvites}`);
3540
+ }
3541
+ if (newSettings.autoAcceptGroupInvites !== void 0) {
3542
+ effectiveAutoAcceptGroupInvites = newSettings.autoAcceptGroupInvites;
3543
+ runtime.log?.(`[tlon] Settings: autoAcceptGroupInvites = ${effectiveAutoAcceptGroupInvites}`);
3544
+ }
3545
+ if (newSettings.groupInviteAllowlist !== void 0) {
3546
+ effectiveGroupInviteAllowlist = newSettings.groupInviteAllowlist;
3547
+ runtime.log?.(`[tlon] Settings: groupInviteAllowlist updated to ${effectiveGroupInviteAllowlist.join(", ")}`);
3548
+ }
3549
+ if (newSettings.defaultAuthorizedShips !== void 0) runtime.log?.(`[tlon] Settings: defaultAuthorizedShips updated to ${(newSettings.defaultAuthorizedShips || []).join(", ")}`);
3550
+ if (newSettings.autoDiscoverChannels !== void 0) {
3551
+ effectiveAutoDiscoverChannels = newSettings.autoDiscoverChannels;
3552
+ runtime.log?.(`[tlon] Settings: autoDiscoverChannels = ${effectiveAutoDiscoverChannels}`);
3553
+ }
3554
+ if (newSettings.ownerShip !== void 0) {
3555
+ effectiveOwnerShip = newSettings.ownerShip ? normalizeShip(newSettings.ownerShip) : account.ownerShip ? normalizeShip(account.ownerShip) : null;
3556
+ runtime.log?.(`[tlon] Settings: ownerShip = ${effectiveOwnerShip}`);
3557
+ }
3558
+ if (newSettings.pendingApprovals !== void 0) {
3559
+ pendingApprovals = newSettings.pendingApprovals;
3560
+ runtime.log?.(`[tlon] Settings: pendingApprovals updated (${pendingApprovals.length} items)`);
3561
+ }
3562
+ });
3563
+ try {
3564
+ await settingsManager.startSubscription();
3565
+ } catch (err) {
3566
+ runtime.log?.(`[tlon] Settings subscription not available: ${String(err)}`);
3567
+ }
3568
+ try {
3569
+ await api.subscribe({
3570
+ app: "groups",
3571
+ path: "/groups/ui",
3572
+ event: async (event) => {
3573
+ try {
3574
+ if (event && typeof event === "object") {
3575
+ if (event.channels && typeof event.channels === "object") {
3576
+ const channels = event.channels;
3577
+ for (const [channelNest, _channelData] of Object.entries(channels)) {
3578
+ if (!channelNest.startsWith("chat/")) continue;
3579
+ if (!watchedChannels.has(channelNest)) {
3580
+ watchedChannels.add(channelNest);
3581
+ runtime.log?.(`[tlon] Auto-detected new channel (invite accepted): ${channelNest}`);
3582
+ if (effectiveAutoAcceptGroupInvites) try {
3583
+ const currentChannels = currentSettings.groupChannels || [];
3584
+ if (!currentChannels.includes(channelNest)) {
3585
+ const updatedChannels = [...currentChannels, channelNest];
3586
+ await api.poke({
3587
+ app: "settings",
3588
+ mark: "settings-event",
3589
+ json: { "put-entry": {
3590
+ "bucket-key": "tlon",
3591
+ "entry-key": "groupChannels",
3592
+ value: updatedChannels,
3593
+ desk: "moltbot"
3594
+ } }
3595
+ });
3596
+ runtime.log?.(`[tlon] Persisted ${channelNest} to settings store`);
3597
+ }
3598
+ } catch (err) {
3599
+ runtime.error?.(`[tlon] Failed to persist channel to settings: ${String(err)}`);
3600
+ }
3601
+ }
3602
+ }
3603
+ }
3604
+ if (event.join && typeof event.join === "object") {
3605
+ const join = event.join;
3606
+ if (join.channels) for (const channelNest of join.channels) {
3607
+ if (!channelNest.startsWith("chat/")) continue;
3608
+ if (!watchedChannels.has(channelNest)) {
3609
+ watchedChannels.add(channelNest);
3610
+ runtime.log?.(`[tlon] Auto-detected joined channel: ${channelNest}`);
3611
+ if (effectiveAutoAcceptGroupInvites) try {
3612
+ const currentChannels = currentSettings.groupChannels || [];
3613
+ if (!currentChannels.includes(channelNest)) {
3614
+ const updatedChannels = [...currentChannels, channelNest];
3615
+ await api.poke({
3616
+ app: "settings",
3617
+ mark: "settings-event",
3618
+ json: { "put-entry": {
3619
+ "bucket-key": "tlon",
3620
+ "entry-key": "groupChannels",
3621
+ value: updatedChannels,
3622
+ desk: "moltbot"
3623
+ } }
3624
+ });
3625
+ runtime.log?.(`[tlon] Persisted ${channelNest} to settings store`);
3626
+ }
3627
+ } catch (err) {
3628
+ runtime.error?.(`[tlon] Failed to persist channel to settings: ${String(err)}`);
3629
+ }
3630
+ }
3631
+ }
3632
+ }
3633
+ }
3634
+ } catch (error) {
3635
+ runtime.error?.(`[tlon] Error handling groups-ui event: ${error?.message ?? String(error)}`);
3636
+ }
3637
+ },
3638
+ err: (error) => {
3639
+ runtime.error?.(`[tlon] Groups-ui subscription error: ${String(error)}`);
3640
+ },
3641
+ quit: () => {
3642
+ runtime.log?.("[tlon] Groups-ui subscription ended");
3643
+ }
3644
+ });
3645
+ runtime.log?.("[tlon] Subscribed to groups-ui for real-time channel detection");
3646
+ } catch (err) {
3647
+ runtime.log?.(`[tlon] Groups-ui subscription failed (will rely on polling): ${String(err)}`);
3648
+ }
3649
+ {
3650
+ const processedGroupInvites = /* @__PURE__ */ new Set();
3651
+ const processPendingInvites = async (foreigns) => {
3652
+ if (!foreigns || typeof foreigns !== "object") return;
3653
+ for (const [groupFlag, foreign] of Object.entries(foreigns)) {
3654
+ if (processedGroupInvites.has(groupFlag)) continue;
3655
+ if (!foreign.invites || foreign.invites.length === 0) continue;
3656
+ const validInvite = foreign.invites.find((inv) => inv.valid);
3657
+ if (!validInvite) continue;
3658
+ const inviterShip = validInvite.from;
3659
+ const normalizedInviter = normalizeShip(inviterShip);
3660
+ if (isOwner(inviterShip)) {
3661
+ try {
3662
+ await api.poke({
3663
+ app: "groups",
3664
+ mark: "group-join",
3665
+ json: {
3666
+ flag: groupFlag,
3667
+ "join-all": true
3668
+ }
3669
+ });
3670
+ processedGroupInvites.add(groupFlag);
3671
+ runtime.log?.(`[tlon] Auto-accepted group invite from owner: ${groupFlag}`);
3672
+ } catch (err) {
3673
+ runtime.error?.(`[tlon] Failed to accept group invite from owner: ${String(err)}`);
3674
+ }
3675
+ continue;
3676
+ }
3677
+ if (!effectiveAutoAcceptGroupInvites) {
3678
+ if (effectiveOwnerShip) {
3679
+ await queueApprovalRequest(createPendingApproval({
3680
+ type: "group",
3681
+ requestingShip: inviterShip,
3682
+ groupFlag
3683
+ }));
3684
+ processedGroupInvites.add(groupFlag);
3685
+ }
3686
+ continue;
3687
+ }
3688
+ if (!(effectiveGroupInviteAllowlist.length > 0 ? effectiveGroupInviteAllowlist.map((s) => normalizeShip(s)).some((s) => s === normalizedInviter) : false)) {
3689
+ if (effectiveOwnerShip) {
3690
+ await queueApprovalRequest(createPendingApproval({
3691
+ type: "group",
3692
+ requestingShip: inviterShip,
3693
+ groupFlag
3694
+ }));
3695
+ processedGroupInvites.add(groupFlag);
3696
+ } else {
3697
+ runtime.log?.(`[tlon] Rejected group invite from ${inviterShip} (not in groupInviteAllowlist): ${groupFlag}`);
3698
+ processedGroupInvites.add(groupFlag);
3699
+ }
3700
+ continue;
3701
+ }
3702
+ try {
3703
+ await api.poke({
3704
+ app: "groups",
3705
+ mark: "group-join",
3706
+ json: {
3707
+ flag: groupFlag,
3708
+ "join-all": true
3709
+ }
3710
+ });
3711
+ processedGroupInvites.add(groupFlag);
3712
+ runtime.log?.(`[tlon] Auto-accepted group invite: ${groupFlag} (from ${validInvite.from})`);
3713
+ } catch (err) {
3714
+ runtime.error?.(`[tlon] Failed to auto-accept group ${groupFlag}: ${String(err)}`);
3715
+ }
3716
+ }
3717
+ };
3718
+ if (initForeigns) await processPendingInvites(initForeigns);
3719
+ try {
3720
+ await api.subscribe({
3721
+ app: "groups",
3722
+ path: "/v1/foreigns",
3723
+ event: (data) => {
3724
+ (async () => {
3725
+ try {
3726
+ await processPendingInvites(data);
3727
+ } catch (error) {
3728
+ runtime.error?.(`[tlon] Error handling foreigns event: ${error?.message ?? String(error)}`);
3729
+ }
3730
+ })();
3731
+ },
3732
+ err: (error) => {
3733
+ runtime.error?.(`[tlon] Foreigns subscription error: ${String(error)}`);
3734
+ },
3735
+ quit: () => {
3736
+ runtime.log?.("[tlon] Foreigns subscription ended");
3737
+ }
3738
+ });
3739
+ runtime.log?.("[tlon] Subscribed to foreigns (/v1/foreigns) for auto-accepting group invites");
3740
+ } catch (err) {
3741
+ runtime.log?.(`[tlon] Foreigns subscription failed: ${String(err)}`);
3742
+ }
3743
+ }
3744
+ if (effectiveAutoDiscoverChannels) {
3745
+ const discoveredChannels = await fetchAllChannels(api, runtime);
3746
+ for (const channelNest of discoveredChannels) watchedChannels.add(channelNest);
3747
+ runtime.log?.(`[tlon] Watching ${watchedChannels.size} channel(s)`);
3748
+ }
3749
+ for (const channelNest of watchedChannels) runtime.log?.(`[tlon] Watching channel: ${channelNest}`);
3750
+ runtime.log?.("[tlon] All subscriptions registered, connecting to SSE stream...");
3751
+ await api.connect();
3752
+ runtime.log?.("[tlon] Connected! Firehose subscriptions active");
3753
+ const pollInterval = setInterval(async () => {
3754
+ if (!opts.abortSignal?.aborted) try {
3755
+ if (effectiveAutoDiscoverChannels) {
3756
+ const discoveredChannels = await fetchAllChannels(api, runtime);
3757
+ for (const channelNest of discoveredChannels) if (!watchedChannels.has(channelNest)) {
3758
+ watchedChannels.add(channelNest);
3759
+ runtime.log?.(`[tlon] Now watching new channel: ${channelNest}`);
3760
+ }
3761
+ }
3762
+ } catch (error) {
3763
+ runtime.error?.(`[tlon] Channel refresh error: ${error?.message ?? String(error)}`);
3764
+ }
3765
+ }, 120 * 1e3);
3766
+ if (opts.abortSignal) {
3767
+ const signal = opts.abortSignal;
3768
+ await new Promise((resolve) => {
3769
+ signal.addEventListener("abort", () => {
3770
+ clearInterval(pollInterval);
3771
+ resolve(null);
3772
+ }, { once: true });
3773
+ });
3774
+ } else await new Promise(() => {});
3775
+ } finally {
3776
+ try {
3777
+ await api?.close();
3778
+ } catch (error) {
3779
+ runtime.error?.(`[tlon] Cleanup error: ${error?.message ?? String(error)}`);
3780
+ }
3781
+ }
3782
+ }
3783
+ //#endregion
3784
+ //#region extensions/tlon/src/urbit/upload.ts
3785
+ /**
3786
+ * Upload an image from a URL to Tlon storage.
3787
+ */
3788
+ /**
3789
+ * Fetch an image from a URL and upload it to Tlon storage.
3790
+ * Returns the uploaded URL, or falls back to the original URL on error.
3791
+ *
3792
+ * Note: configureClient must be called before using this function.
3793
+ */
3794
+ async function uploadImageFromUrl(imageUrl) {
3795
+ try {
3796
+ const url = new URL(imageUrl);
3797
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
3798
+ console.warn(`[tlon] Rejected non-http(s) URL: ${imageUrl}`);
3799
+ return imageUrl;
3800
+ }
3801
+ const { response, release } = await fetchWithSsrFGuard({
3802
+ url: imageUrl,
3803
+ init: { method: "GET" },
3804
+ policy: /* @__PURE__ */ getDefaultSsrFPolicy(),
3805
+ auditContext: "tlon-upload-image"
3806
+ });
3807
+ try {
3808
+ if (!response.ok) {
3809
+ console.warn(`[tlon] Failed to fetch image from ${imageUrl}: ${response.status}`);
3810
+ return imageUrl;
3811
+ }
3812
+ const contentType = response.headers.get("content-type") || "image/png";
3813
+ return (await uploadFile({
3814
+ blob: await response.blob(),
3815
+ fileName: new URL(imageUrl).pathname.split("/").pop() || `upload-${Date.now()}.png`,
3816
+ contentType
3817
+ })).url;
3818
+ } finally {
3819
+ await release();
3820
+ }
3821
+ } catch (err) {
3822
+ console.warn(`[tlon] Failed to upload image, using original URL: ${err}`);
3823
+ return imageUrl;
3824
+ }
3825
+ }
3826
+ //#endregion
3827
+ //#region extensions/tlon/src/channel.runtime.ts
3828
+ async function createHttpPokeApi(params) {
3829
+ const ssrfPolicy = ssrfPolicyFromAllowPrivateNetwork(params.allowPrivateNetwork);
3830
+ const cookie = await authenticate(params.url, params.code, { ssrfPolicy });
3831
+ const channelPath = `/~/channel/${`${Math.floor(Date.now() / 1e3)}-${crypto.randomUUID()}`}`;
3832
+ const shipName = params.ship.replace(/^~/, "");
3833
+ return {
3834
+ poke: async (pokeParams) => {
3835
+ const pokeId = Date.now();
3836
+ const pokeData = {
3837
+ id: pokeId,
3838
+ action: "poke",
3839
+ ship: shipName,
3840
+ app: pokeParams.app,
3841
+ mark: pokeParams.mark,
3842
+ json: pokeParams.json
3843
+ };
3844
+ const { response, release } = await urbitFetch({
3845
+ baseUrl: params.url,
3846
+ path: channelPath,
3847
+ init: {
3848
+ method: "PUT",
3849
+ headers: {
3850
+ "Content-Type": "application/json",
3851
+ Cookie: cookie.split(";")[0]
3852
+ },
3853
+ body: JSON.stringify([pokeData])
3854
+ },
3855
+ ssrfPolicy,
3856
+ auditContext: "tlon-poke"
3857
+ });
3858
+ try {
3859
+ if (!response.ok && response.status !== 204) {
3860
+ const errorText = await response.text();
3861
+ throw new Error(`Poke failed: ${response.status} - ${errorText}`);
3862
+ }
3863
+ return pokeId;
3864
+ } finally {
3865
+ await release();
3866
+ }
3867
+ },
3868
+ delete: async () => {}
3869
+ };
3870
+ }
3871
+ function resolveOutboundContext(params) {
3872
+ const account = resolveTlonAccount(params.cfg, params.accountId ?? void 0);
3873
+ if (!account.configured || !account.ship || !account.url || !account.code) throw new Error("Tlon account not configured");
3874
+ const parsed = parseTlonTarget(params.to);
3875
+ if (!parsed) throw new Error(`Invalid Tlon target. Use ${formatTargetHint()}`);
3876
+ return {
3877
+ account,
3878
+ parsed
3879
+ };
3880
+ }
3881
+ function resolveReplyId(replyToId, threadId) {
3882
+ return replyToId ?? threadId ? String(replyToId ?? threadId) : void 0;
3883
+ }
3884
+ async function withHttpPokeAccountApi(account, run) {
3885
+ const api = await createHttpPokeApi({
3886
+ url: account.url,
3887
+ ship: account.ship,
3888
+ code: account.code,
3889
+ allowPrivateNetwork: account.allowPrivateNetwork ?? void 0
3890
+ });
3891
+ try {
3892
+ return await run(api);
3893
+ } finally {
3894
+ try {
3895
+ await api.delete();
3896
+ } catch {}
3897
+ }
3898
+ }
3899
+ const tlonRuntimeOutbound = {
3900
+ deliveryMode: "direct",
3901
+ textChunkLimit: 1e4,
3902
+ resolveTarget: ({ to }) => resolveTlonOutboundTarget(to),
3903
+ sendText: async ({ cfg, to, text, accountId, replyToId, threadId }) => {
3904
+ const { account, parsed } = resolveOutboundContext({
3905
+ cfg,
3906
+ accountId,
3907
+ to
3908
+ });
3909
+ return withHttpPokeAccountApi(account, async (api) => {
3910
+ const fromShip = normalizeShip(account.ship);
3911
+ if (parsed.kind === "dm") return await sendDm({
3912
+ api,
3913
+ fromShip,
3914
+ toShip: parsed.ship,
3915
+ text
3916
+ });
3917
+ return await sendGroupMessage({
3918
+ api,
3919
+ fromShip,
3920
+ hostShip: parsed.hostShip,
3921
+ channelName: parsed.channelName,
3922
+ text,
3923
+ replyToId: resolveReplyId(replyToId, threadId)
3924
+ });
3925
+ });
3926
+ },
3927
+ sendMedia: async ({ cfg, to, text, mediaUrl, accountId, replyToId, threadId }) => {
3928
+ const { account, parsed } = resolveOutboundContext({
3929
+ cfg,
3930
+ accountId,
3931
+ to
3932
+ });
3933
+ configureClient({
3934
+ shipUrl: account.url,
3935
+ shipName: account.ship.replace(/^~/, ""),
3936
+ verbose: false,
3937
+ getCode: async () => account.code
3938
+ });
3939
+ const uploadedUrl = mediaUrl ? await uploadImageFromUrl(mediaUrl) : void 0;
3940
+ return withHttpPokeAccountApi(account, async (api) => {
3941
+ const fromShip = normalizeShip(account.ship);
3942
+ const story = buildMediaStory(text, uploadedUrl);
3943
+ if (parsed.kind === "dm") return await sendDmWithStory({
3944
+ api,
3945
+ fromShip,
3946
+ toShip: parsed.ship,
3947
+ story
3948
+ });
3949
+ return await sendGroupMessageWithStory({
3950
+ api,
3951
+ fromShip,
3952
+ hostShip: parsed.hostShip,
3953
+ channelName: parsed.channelName,
3954
+ story,
3955
+ replyToId: resolveReplyId(replyToId, threadId)
3956
+ });
3957
+ });
3958
+ }
3959
+ };
3960
+ async function probeTlonAccount(account) {
3961
+ try {
3962
+ const ssrfPolicy = ssrfPolicyFromAllowPrivateNetwork(account.allowPrivateNetwork);
3963
+ const cookie = await authenticate(account.url, account.code, { ssrfPolicy });
3964
+ const { response, release } = await urbitFetch({
3965
+ baseUrl: account.url,
3966
+ path: "/~/name",
3967
+ init: {
3968
+ method: "GET",
3969
+ headers: { Cookie: cookie }
3970
+ },
3971
+ ssrfPolicy,
3972
+ timeoutMs: 3e4,
3973
+ auditContext: "tlon-probe-account"
3974
+ });
3975
+ try {
3976
+ if (!response.ok) return {
3977
+ ok: false,
3978
+ error: `Name request failed: ${response.status}`
3979
+ };
3980
+ return { ok: true };
3981
+ } finally {
3982
+ await release();
3983
+ }
3984
+ } catch (error) {
3985
+ return {
3986
+ ok: false,
3987
+ error: error?.message ?? String(error)
3988
+ };
3989
+ }
3990
+ }
3991
+ async function startTlonGatewayAccount(ctx) {
3992
+ const account = ctx.account;
3993
+ ctx.setStatus({
3994
+ accountId: account.accountId,
3995
+ ship: account.ship,
3996
+ url: account.url
3997
+ });
3998
+ ctx.log?.info(`[${account.accountId}] starting Tlon provider for ${account.ship ?? "tlon"}`);
3999
+ return monitorTlonProvider({
4000
+ runtime: ctx.runtime,
4001
+ abortSignal: ctx.abortSignal,
4002
+ accountId: account.accountId
4003
+ });
4004
+ }
4005
+ //#endregion
4006
+ export { probeTlonAccount, startTlonGatewayAccount, tlonRuntimeOutbound, tlonSetupWizard };