@celljs/ta 4.12.0 → 4.13.0

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 (629) hide show
  1. package/README.en.md +2 -2
  2. package/README.md +2 -2
  3. package/dist/cli.mjs +1006 -164
  4. package/dist/gateway.mjs +161 -2
  5. package/dist/pi/CHANGELOG.md +11 -0
  6. package/dist/pi/package.json +1 -1
  7. package/dist/pi/packages/ta-agents/README.en.md +1 -1
  8. package/dist/pi/packages/ta-agents/README.md +1 -1
  9. package/dist/pi/packages/ta-agents/extension/index.mjs +75 -11
  10. package/dist/pi/packages/ta-agents/lib/acp-protocol.d.ts +2 -2
  11. package/dist/pi/packages/ta-agents/lib/acp-protocol.js +5 -2
  12. package/dist/pi/packages/ta-agents/lib/agent-prompt.d.ts +6 -4
  13. package/dist/pi/packages/ta-agents/lib/agent-prompt.js +7 -5
  14. package/dist/pi/packages/ta-agents/lib/agent-session.d.ts +2 -0
  15. package/dist/pi/packages/ta-agents/lib/agent-session.js +7 -0
  16. package/dist/pi/packages/ta-agents/lib/agent-tool.d.ts +2 -0
  17. package/dist/pi/packages/ta-agents/lib/agent-tool.js +44 -3
  18. package/dist/pi/packages/ta-agents/lib/agent-turn.d.ts +12 -2
  19. package/dist/pi/packages/ta-agents/lib/agent-turn.js +29 -4
  20. package/dist/pi/packages/ta-agents/package.json +1 -1
  21. package/dist/pi/packages/ta-bots/extension/index.mjs +51 -0
  22. package/dist/pi/packages/ta-bots/host/index.mjs +157 -0
  23. package/dist/pi/packages/ta-bots/package.json +7 -2
  24. package/dist/pi/packages/ta-changes/extension/index.mjs +51 -0
  25. package/dist/pi/packages/ta-changes/package.json +8 -2
  26. package/dist/pi/packages/ta-channels/README.en.md +3 -1
  27. package/dist/pi/packages/ta-channels/README.md +3 -1
  28. package/dist/pi/packages/ta-channels/extension/index.mjs +55 -2
  29. package/dist/pi/packages/ta-channels/host/index.mjs +268 -8
  30. package/dist/pi/packages/ta-channels/lib/channels-model.d.ts +25 -0
  31. package/dist/pi/packages/ta-channels/lib/channels-util.js +8 -2
  32. package/dist/pi/packages/ta-channels/lib/i18n.d.ts +1 -0
  33. package/dist/pi/packages/ta-channels/lib/i18n.js +2 -0
  34. package/dist/pi/packages/ta-channels/lib/room.d.ts +0 -4
  35. package/dist/pi/packages/ta-channels/lib/room.js +31 -5
  36. package/dist/pi/packages/ta-channels/lib/style.d.ts +1 -1
  37. package/dist/pi/packages/ta-channels/lib/style.js +7 -13
  38. package/dist/pi/packages/ta-channels/lib/team-view.d.ts +19 -0
  39. package/dist/pi/packages/ta-channels/lib/team-view.js +45 -0
  40. package/dist/pi/packages/ta-channels/lib/team.d.ts +20 -4
  41. package/dist/pi/packages/ta-channels/lib/team.js +87 -6
  42. package/dist/pi/packages/ta-channels/package.json +26 -2
  43. package/dist/pi/packages/ta-channels/web/index.js +137 -27
  44. package/dist/pi/packages/ta-computer-use/package.json +1 -1
  45. package/dist/pi/packages/ta-cron/README.en.md +2 -2
  46. package/dist/pi/packages/ta-cron/README.md +2 -2
  47. package/dist/pi/packages/ta-cron/extension/index.mjs +91 -257
  48. package/dist/pi/packages/ta-cron/host/index.mjs +9 -0
  49. package/dist/pi/packages/ta-cron/lib/chat-task.d.ts +16 -15
  50. package/dist/pi/packages/ta-cron/lib/chat-task.js +45 -36
  51. package/dist/pi/packages/ta-cron/lib/extension.js +11 -7
  52. package/dist/pi/packages/ta-cron/lib/i18n.d.ts +5 -7
  53. package/dist/pi/packages/ta-cron/lib/i18n.js +10 -14
  54. package/dist/pi/packages/ta-cron/lib/index.js +0 -2
  55. package/dist/pi/packages/ta-cron/lib/page.d.ts +5 -0
  56. package/dist/pi/packages/ta-cron/lib/page.js +24 -0
  57. package/dist/pi/packages/ta-cron/lib/style.d.ts +1 -1
  58. package/dist/pi/packages/ta-cron/lib/style.js +8 -0
  59. package/dist/pi/packages/ta-cron/lib/task-change.d.ts +11 -0
  60. package/dist/pi/packages/ta-cron/lib/task-change.js +43 -0
  61. package/dist/pi/packages/ta-cron/lib/task-extension.d.ts +3 -0
  62. package/dist/pi/packages/ta-cron/lib/task-extension.js +2 -0
  63. package/dist/pi/packages/ta-cron/lib/task-util.d.ts +5 -0
  64. package/dist/pi/packages/ta-cron/lib/task-util.js +13 -0
  65. package/dist/pi/packages/ta-cron/lib/tasks-view.js +26 -2
  66. package/dist/pi/packages/ta-cron/package.json +10 -2
  67. package/dist/pi/packages/ta-cron/web/index.js +607 -784
  68. package/dist/pi/packages/ta-extensions/README.en.md +1 -2
  69. package/dist/pi/packages/ta-extensions/README.md +1 -2
  70. package/dist/pi/packages/ta-extensions/lib/i18n.d.ts +0 -4
  71. package/dist/pi/packages/ta-extensions/lib/i18n.js +2 -10
  72. package/dist/pi/packages/ta-extensions/lib/index.js +0 -2
  73. package/dist/pi/packages/ta-extensions/package.json +10 -2
  74. package/dist/pi/packages/ta-extensions/skills/ta-package/SKILL.md +15 -11
  75. package/dist/pi/packages/ta-extensions/web/index.js +176 -97
  76. package/dist/pi/packages/ta-games/package.json +8 -2
  77. package/dist/pi/packages/ta-glance/README.en.md +1 -0
  78. package/dist/pi/packages/ta-glance/README.md +1 -0
  79. package/dist/pi/packages/ta-glance/extension/index.mjs +425 -3
  80. package/dist/pi/packages/ta-glance/lib/card.js +38 -12
  81. package/dist/pi/packages/ta-glance/lib/extension.d.ts +3 -0
  82. package/dist/pi/packages/ta-glance/lib/extension.js +10 -0
  83. package/dist/pi/packages/ta-glance/lib/glance-ask.d.ts +15 -0
  84. package/dist/pi/packages/ta-glance/lib/glance-ask.js +97 -0
  85. package/dist/pi/packages/ta-glance/lib/glance-prompt.d.ts +1 -1
  86. package/dist/pi/packages/ta-glance/lib/glance-prompt.js +3 -3
  87. package/dist/pi/packages/ta-glance/lib/glance-protocol.d.ts +2 -0
  88. package/dist/pi/packages/ta-glance/lib/glance-protocol.js +3 -1
  89. package/dist/pi/packages/ta-glance/lib/glance-spec.d.ts +6 -1
  90. package/dist/pi/packages/ta-glance/lib/glance-spec.js +41 -7
  91. package/dist/pi/packages/ta-glance/lib/i18n.d.ts +5 -0
  92. package/dist/pi/packages/ta-glance/lib/i18n.js +9 -0
  93. package/dist/pi/packages/ta-glance/lib/index.js +4 -1
  94. package/dist/pi/packages/ta-glance/lib/style.d.ts +1 -1
  95. package/dist/pi/packages/ta-glance/lib/style.js +9 -1
  96. package/dist/pi/packages/ta-glance/package.json +1 -1
  97. package/dist/pi/packages/ta-glance/web/index.js +87 -19
  98. package/dist/pi/packages/ta-initiative/README.en.md +66 -0
  99. package/dist/pi/packages/ta-initiative/README.md +66 -0
  100. package/dist/pi/packages/ta-initiative/extension/index.mjs +720 -0
  101. package/dist/pi/packages/ta-initiative/host/index.mjs +1169 -0
  102. package/dist/pi/packages/ta-initiative/lib/chat-kinds.d.ts +4 -0
  103. package/dist/pi/packages/ta-initiative/lib/chat-kinds.js +17 -0
  104. package/dist/pi/packages/ta-initiative/lib/chat-proposals.d.ts +28 -0
  105. package/dist/pi/packages/ta-initiative/lib/chat-proposals.js +79 -0
  106. package/dist/pi/packages/ta-initiative/lib/conversation.d.ts +4 -0
  107. package/dist/pi/packages/ta-initiative/lib/conversation.js +27 -0
  108. package/dist/pi/packages/ta-initiative/lib/cron-proposals.d.ts +23 -0
  109. package/dist/pi/packages/ta-initiative/lib/cron-proposals.js +94 -0
  110. package/dist/pi/packages/ta-initiative/lib/event-proposals.d.ts +13 -0
  111. package/dist/pi/packages/ta-initiative/lib/event-proposals.js +76 -0
  112. package/dist/pi/packages/ta-initiative/lib/extension.d.ts +30 -0
  113. package/dist/pi/packages/ta-initiative/lib/extension.js +238 -0
  114. package/dist/pi/packages/ta-initiative/lib/host.d.ts +4 -0
  115. package/dist/pi/packages/ta-initiative/lib/host.js +11 -0
  116. package/dist/pi/packages/ta-initiative/lib/i18n.d.ts +79 -0
  117. package/dist/pi/packages/ta-initiative/lib/i18n.js +159 -0
  118. package/dist/pi/packages/ta-initiative/lib/inbox-util.d.ts +19 -0
  119. package/dist/pi/packages/ta-initiative/lib/inbox-util.js +45 -0
  120. package/dist/pi/packages/ta-initiative/lib/inbox.d.ts +23 -0
  121. package/dist/pi/packages/ta-initiative/lib/inbox.js +142 -0
  122. package/dist/pi/packages/ta-initiative/lib/index.d.ts +10 -0
  123. package/dist/pi/packages/ta-initiative/lib/index.js +121 -0
  124. package/dist/pi/packages/ta-initiative/lib/initiative-protocol.d.ts +320 -0
  125. package/dist/pi/packages/ta-initiative/lib/initiative-protocol.js +96 -0
  126. package/dist/pi/packages/ta-initiative/lib/initiative-service.d.ts +37 -0
  127. package/dist/pi/packages/ta-initiative/lib/initiative-service.js +104 -0
  128. package/dist/pi/packages/ta-initiative/lib/initiative-store.d.ts +44 -0
  129. package/dist/pi/packages/ta-initiative/lib/initiative-store.js +112 -0
  130. package/dist/pi/packages/ta-initiative/lib/level-util.d.ts +22 -0
  131. package/dist/pi/packages/ta-initiative/lib/level-util.js +86 -0
  132. package/dist/pi/packages/ta-initiative/lib/material-util.d.ts +34 -0
  133. package/dist/pi/packages/ta-initiative/lib/material-util.js +155 -0
  134. package/dist/pi/packages/ta-initiative/lib/notices.d.ts +13 -0
  135. package/dist/pi/packages/ta-initiative/lib/notices.js +65 -0
  136. package/dist/pi/packages/ta-initiative/lib/notify-util.d.ts +25 -0
  137. package/dist/pi/packages/ta-initiative/lib/notify-util.js +60 -0
  138. package/dist/pi/packages/ta-initiative/lib/pace-util.d.ts +21 -0
  139. package/dist/pi/packages/ta-initiative/lib/pace-util.js +60 -0
  140. package/dist/pi/packages/ta-initiative/lib/page-initiative.d.ts +9 -0
  141. package/dist/pi/packages/ta-initiative/lib/page-initiative.js +40 -0
  142. package/dist/pi/packages/ta-initiative/lib/proposal-book.d.ts +61 -0
  143. package/dist/pi/packages/ta-initiative/lib/proposal-book.js +397 -0
  144. package/dist/pi/packages/ta-initiative/lib/react.d.ts +11 -0
  145. package/dist/pi/packages/ta-initiative/lib/react.js +16 -0
  146. package/dist/pi/packages/ta-initiative/lib/review-service.d.ts +32 -0
  147. package/dist/pi/packages/ta-initiative/lib/review-service.js +155 -0
  148. package/dist/pi/packages/ta-initiative/lib/server-texts.d.ts +7 -0
  149. package/dist/pi/packages/ta-initiative/lib/server-texts.js +17 -0
  150. package/dist/pi/packages/ta-initiative/lib/settings.d.ts +10 -0
  151. package/dist/pi/packages/ta-initiative/lib/settings.js +226 -0
  152. package/dist/pi/packages/ta-initiative/lib/style.d.ts +4 -0
  153. package/dist/pi/packages/ta-initiative/lib/style.js +56 -0
  154. package/dist/pi/packages/ta-initiative/lib/tool.d.ts +106 -0
  155. package/dist/pi/packages/ta-initiative/lib/tool.js +98 -0
  156. package/dist/pi/packages/ta-initiative/package.json +63 -0
  157. package/dist/pi/packages/ta-initiative/web/index.js +1226 -0
  158. package/dist/pi/packages/ta-launcher/README.en.md +2 -1
  159. package/dist/pi/packages/ta-launcher/README.md +2 -1
  160. package/dist/pi/packages/ta-launcher/lib/i18n.d.ts +2 -0
  161. package/dist/pi/packages/ta-launcher/lib/i18n.js +4 -0
  162. package/dist/pi/packages/ta-launcher/lib/launcher-view.js +32 -0
  163. package/dist/pi/packages/ta-launcher/lib/style.d.ts +1 -1
  164. package/dist/pi/packages/ta-launcher/lib/style.js +11 -0
  165. package/dist/pi/packages/ta-launcher/package.json +1 -1
  166. package/dist/pi/packages/ta-launcher/web/index.js +58 -1
  167. package/dist/pi/packages/ta-manual/lib/pictures-b.js +29 -0
  168. package/dist/pi/packages/ta-manual/lib/pictures-c.js +109 -2
  169. package/dist/pi/packages/ta-manual/lib/topics.d.ts +4 -0
  170. package/dist/pi/packages/ta-manual/lib/topics.js +123 -11
  171. package/dist/pi/packages/ta-manual/package.json +1 -1
  172. package/dist/pi/packages/ta-manual/skills/ta-manual/SKILL.md +45 -10
  173. package/dist/pi/packages/ta-manual/web/index.js +567 -12
  174. package/dist/pi/packages/ta-moments/README.en.md +29 -0
  175. package/dist/pi/packages/ta-moments/README.md +29 -0
  176. package/dist/pi/packages/ta-moments/extension/index.mjs +1766 -0
  177. package/dist/pi/packages/ta-moments/host/index.mjs +2394 -0
  178. package/dist/pi/packages/ta-moments/lib/brief-util.d.ts +30 -0
  179. package/dist/pi/packages/ta-moments/lib/brief-util.js +92 -0
  180. package/dist/pi/packages/ta-moments/lib/context.d.ts +18 -0
  181. package/dist/pi/packages/ta-moments/lib/context.js +35 -0
  182. package/dist/pi/packages/ta-moments/lib/draft-card.d.ts +6 -0
  183. package/dist/pi/packages/ta-moments/lib/draft-card.js +60 -0
  184. package/dist/pi/packages/ta-moments/lib/editor.d.ts +16 -0
  185. package/dist/pi/packages/ta-moments/lib/editor.js +126 -0
  186. package/dist/pi/packages/ta-moments/lib/extension.d.ts +24 -0
  187. package/dist/pi/packages/ta-moments/lib/extension.js +136 -0
  188. package/dist/pi/packages/ta-moments/lib/friends.d.ts +13 -0
  189. package/dist/pi/packages/ta-moments/lib/friends.js +27 -0
  190. package/dist/pi/packages/ta-moments/lib/host.d.ts +4 -0
  191. package/dist/pi/packages/ta-moments/lib/host.js +11 -0
  192. package/dist/pi/packages/ta-moments/lib/i18n.d.ts +92 -0
  193. package/dist/pi/packages/ta-moments/lib/i18n.js +201 -0
  194. package/dist/pi/packages/ta-moments/lib/image-util.d.ts +18 -0
  195. package/dist/pi/packages/ta-moments/lib/image-util.js +71 -0
  196. package/dist/pi/packages/ta-moments/lib/index.d.ts +8 -0
  197. package/dist/pi/packages/ta-moments/lib/index.js +50 -0
  198. package/dist/pi/packages/ta-moments/lib/moments-host.d.ts +133 -0
  199. package/dist/pi/packages/ta-moments/lib/moments-host.js +821 -0
  200. package/dist/pi/packages/ta-moments/lib/moments-protocol.d.ts +334 -0
  201. package/dist/pi/packages/ta-moments/lib/moments-protocol.js +99 -0
  202. package/dist/pi/packages/ta-moments/lib/page.d.ts +7 -0
  203. package/dist/pi/packages/ta-moments/lib/page.js +307 -0
  204. package/dist/pi/packages/ta-moments/lib/post-util.d.ts +31 -0
  205. package/dist/pi/packages/ta-moments/lib/post-util.js +205 -0
  206. package/dist/pi/packages/ta-moments/lib/server-texts.d.ts +29 -0
  207. package/dist/pi/packages/ta-moments/lib/server-texts.js +104 -0
  208. package/dist/pi/packages/ta-moments/lib/store.d.ts +33 -0
  209. package/dist/pi/packages/ta-moments/lib/store.js +108 -0
  210. package/dist/pi/packages/ta-moments/lib/style.d.ts +4 -0
  211. package/dist/pi/packages/ta-moments/lib/style.js +155 -0
  212. package/dist/pi/packages/ta-moments/lib/talk-host.d.ts +112 -0
  213. package/dist/pi/packages/ta-moments/lib/talk-host.js +582 -0
  214. package/dist/pi/packages/ta-moments/lib/talk-util.d.ts +26 -0
  215. package/dist/pi/packages/ta-moments/lib/talk-util.js +145 -0
  216. package/dist/pi/packages/ta-moments/lib/tool.d.ts +48 -0
  217. package/dist/pi/packages/ta-moments/lib/tool.js +56 -0
  218. package/dist/pi/packages/ta-moments/package.json +61 -0
  219. package/dist/pi/packages/ta-moments/web/index.js +1987 -0
  220. package/dist/pi/packages/ta-nearby/README.en.md +33 -0
  221. package/dist/pi/packages/ta-nearby/README.md +33 -0
  222. package/dist/pi/packages/ta-nearby/extension/index.mjs +389 -0
  223. package/dist/pi/packages/ta-nearby/host/index.mjs +1859 -0
  224. package/dist/pi/packages/ta-nearby/lib/extension.d.ts +27 -0
  225. package/dist/pi/packages/ta-nearby/lib/extension.js +190 -0
  226. package/dist/pi/packages/ta-nearby/lib/host.d.ts +7 -0
  227. package/dist/pi/packages/ta-nearby/lib/host.js +20 -0
  228. package/dist/pi/packages/ta-nearby/lib/i18n.d.ts +92 -0
  229. package/dist/pi/packages/ta-nearby/lib/i18n.js +183 -0
  230. package/dist/pi/packages/ta-nearby/lib/index.d.ts +8 -0
  231. package/dist/pi/packages/ta-nearby/lib/index.js +38 -0
  232. package/dist/pi/packages/ta-nearby/lib/nearby-crypto.d.ts +31 -0
  233. package/dist/pi/packages/ta-nearby/lib/nearby-crypto.js +59 -0
  234. package/dist/pi/packages/ta-nearby/lib/nearby-meet.d.ts +35 -0
  235. package/dist/pi/packages/ta-nearby/lib/nearby-meet.js +93 -0
  236. package/dist/pi/packages/ta-nearby/lib/nearby-net.d.ts +59 -0
  237. package/dist/pi/packages/ta-nearby/lib/nearby-net.js +253 -0
  238. package/dist/pi/packages/ta-nearby/lib/nearby-protocol.d.ts +274 -0
  239. package/dist/pi/packages/ta-nearby/lib/nearby-protocol.js +31 -0
  240. package/dist/pi/packages/ta-nearby/lib/nearby-service.d.ts +199 -0
  241. package/dist/pi/packages/ta-nearby/lib/nearby-service.js +1012 -0
  242. package/dist/pi/packages/ta-nearby/lib/nearby-spot.d.ts +50 -0
  243. package/dist/pi/packages/ta-nearby/lib/nearby-spot.js +167 -0
  244. package/dist/pi/packages/ta-nearby/lib/page.d.ts +52 -0
  245. package/dist/pi/packages/ta-nearby/lib/page.js +588 -0
  246. package/dist/pi/packages/ta-nearby/lib/react.d.ts +8 -0
  247. package/dist/pi/packages/ta-nearby/lib/react.js +8 -0
  248. package/dist/pi/packages/ta-nearby/lib/server-texts.d.ts +45 -0
  249. package/dist/pi/packages/ta-nearby/lib/server-texts.js +148 -0
  250. package/dist/pi/packages/ta-nearby/lib/style.d.ts +4 -0
  251. package/dist/pi/packages/ta-nearby/lib/style.js +92 -0
  252. package/dist/pi/packages/ta-nearby/package.json +65 -0
  253. package/dist/pi/packages/ta-nearby/web/index.js +1055 -0
  254. package/dist/pi/packages/ta-notify/README.en.md +3 -1
  255. package/dist/pi/packages/ta-notify/README.md +3 -1
  256. package/dist/pi/packages/ta-notify/extension/index.mjs +64 -0
  257. package/dist/pi/packages/ta-notify/host/index.mjs +24 -1
  258. package/dist/pi/packages/ta-notify/lib/extension.d.ts +4 -1
  259. package/dist/pi/packages/ta-notify/lib/extension.js +20 -1
  260. package/dist/pi/packages/ta-notify/lib/notify-protocol.d.ts +23 -3
  261. package/dist/pi/packages/ta-notify/lib/notify-service.d.ts +4 -2
  262. package/dist/pi/packages/ta-notify/lib/notify-service.js +27 -2
  263. package/dist/pi/packages/ta-notify/lib/style.d.ts +1 -1
  264. package/dist/pi/packages/ta-notify/lib/style.js +1 -1
  265. package/dist/pi/packages/ta-notify/lib/watcher.js +2 -1
  266. package/dist/pi/packages/ta-notify/package.json +7 -2
  267. package/dist/pi/packages/ta-notify/web/index.js +3 -2
  268. package/dist/pi/packages/ta-recall/README.en.md +15 -6
  269. package/dist/pi/packages/ta-recall/README.md +15 -6
  270. package/dist/pi/packages/ta-recall/extension/index.mjs +289 -133
  271. package/dist/pi/packages/ta-recall/host/index.mjs +451 -116
  272. package/dist/pi/packages/ta-recall/lib/block-util.d.ts +11 -0
  273. package/dist/pi/packages/ta-recall/lib/block-util.js +43 -0
  274. package/dist/pi/packages/ta-recall/lib/brief-util.d.ts +25 -0
  275. package/dist/pi/packages/ta-recall/lib/brief-util.js +38 -1
  276. package/dist/pi/packages/ta-recall/lib/composer.d.ts +3 -2
  277. package/dist/pi/packages/ta-recall/lib/composer.js +9 -8
  278. package/dist/pi/packages/ta-recall/lib/extension-util.d.ts +21 -0
  279. package/dist/pi/packages/ta-recall/lib/extension-util.js +104 -0
  280. package/dist/pi/packages/ta-recall/lib/extension.d.ts +3 -3
  281. package/dist/pi/packages/ta-recall/lib/extension.js +30 -22
  282. package/dist/pi/packages/ta-recall/lib/i18n.d.ts +18 -10
  283. package/dist/pi/packages/ta-recall/lib/i18n.js +40 -24
  284. package/dist/pi/packages/ta-recall/lib/index.d.ts +2 -2
  285. package/dist/pi/packages/ta-recall/lib/index.js +5 -4
  286. package/dist/pi/packages/ta-recall/lib/keep-card.d.ts +10 -0
  287. package/dist/pi/packages/ta-recall/lib/keep-card.js +83 -0
  288. package/dist/pi/packages/ta-recall/lib/keep-util.d.ts +15 -0
  289. package/dist/pi/packages/ta-recall/lib/keep-util.js +55 -0
  290. package/dist/pi/packages/ta-recall/lib/recall-protocol.d.ts +92 -18
  291. package/dist/pi/packages/ta-recall/lib/recall-protocol.js +19 -9
  292. package/dist/pi/packages/ta-recall/lib/recall-service.d.ts +16 -6
  293. package/dist/pi/packages/ta-recall/lib/recall-service.js +101 -11
  294. package/dist/pi/packages/ta-recall/lib/requests-util.d.ts +6 -0
  295. package/dist/pi/packages/ta-recall/lib/requests-util.js +37 -0
  296. package/dist/pi/packages/ta-recall/lib/server-texts.d.ts +2 -0
  297. package/dist/pi/packages/ta-recall/lib/server-texts.js +5 -0
  298. package/dist/pi/packages/ta-recall/lib/settings.d.ts +1 -1
  299. package/dist/pi/packages/ta-recall/lib/settings.js +1 -1
  300. package/dist/pi/packages/ta-recall/lib/style.d.ts +1 -1
  301. package/dist/pi/packages/ta-recall/lib/style.js +2 -2
  302. package/dist/pi/packages/ta-recall/lib/tool-line.d.ts +2 -2
  303. package/dist/pi/packages/ta-recall/lib/tool-line.js +10 -5
  304. package/dist/pi/packages/ta-recall/lib/tool.d.ts +14 -5
  305. package/dist/pi/packages/ta-recall/lib/tool.js +29 -17
  306. package/dist/pi/packages/ta-recall/package.json +13 -5
  307. package/dist/pi/packages/ta-recall/web/index.js +393 -153
  308. package/dist/pi/packages/ta-rooms/README.en.md +6 -3
  309. package/dist/pi/packages/ta-rooms/README.md +6 -3
  310. package/dist/pi/packages/ta-rooms/extension/index.mjs +171 -7
  311. package/dist/pi/packages/ta-rooms/host/index.mjs +1002 -234
  312. package/dist/pi/packages/ta-rooms/lib/dialogs.js +5 -0
  313. package/dist/pi/packages/ta-rooms/lib/double-agents.d.ts +26 -0
  314. package/dist/pi/packages/ta-rooms/lib/double-agents.js +84 -0
  315. package/dist/pi/packages/ta-rooms/lib/double-grants.d.ts +22 -0
  316. package/dist/pi/packages/ta-rooms/lib/double-grants.js +140 -0
  317. package/dist/pi/packages/ta-rooms/lib/double-host.d.ts +43 -40
  318. package/dist/pi/packages/ta-rooms/lib/double-host.js +142 -311
  319. package/dist/pi/packages/ta-rooms/lib/double-i18n.d.ts +20 -0
  320. package/dist/pi/packages/ta-rooms/lib/double-i18n.js +40 -0
  321. package/dist/pi/packages/ta-rooms/lib/double-protocol.d.ts +96 -3
  322. package/dist/pi/packages/ta-rooms/lib/double-protocol.js +58 -3
  323. package/dist/pi/packages/ta-rooms/lib/double-tasks.d.ts +82 -0
  324. package/dist/pi/packages/ta-rooms/lib/double-tasks.js +527 -0
  325. package/dist/pi/packages/ta-rooms/lib/double-user.d.ts +19 -0
  326. package/dist/pi/packages/ta-rooms/lib/double-user.js +124 -0
  327. package/dist/pi/packages/ta-rooms/lib/double-util.d.ts +34 -2
  328. package/dist/pi/packages/ta-rooms/lib/double-util.js +60 -2
  329. package/dist/pi/packages/ta-rooms/lib/doubles-store.d.ts +4 -1
  330. package/dist/pi/packages/ta-rooms/lib/doubles-store.js +8 -2
  331. package/dist/pi/packages/ta-rooms/lib/doubles-view.js +7 -2
  332. package/dist/pi/packages/ta-rooms/lib/extension.d.ts +9 -0
  333. package/dist/pi/packages/ta-rooms/lib/extension.js +33 -6
  334. package/dist/pi/packages/ta-rooms/lib/friend-notices.d.ts +12 -0
  335. package/dist/pi/packages/ta-rooms/lib/friend-notices.js +47 -0
  336. package/dist/pi/packages/ta-rooms/lib/friends-view.d.ts +20 -0
  337. package/dist/pi/packages/ta-rooms/lib/friends-view.js +224 -0
  338. package/dist/pi/packages/ta-rooms/lib/host.d.ts +2 -1
  339. package/dist/pi/packages/ta-rooms/lib/host.js +9 -2
  340. package/dist/pi/packages/ta-rooms/lib/i18n.d.ts +23 -2
  341. package/dist/pi/packages/ta-rooms/lib/i18n.js +60 -18
  342. package/dist/pi/packages/ta-rooms/lib/index.js +18 -1
  343. package/dist/pi/packages/ta-rooms/lib/members-view.js +12 -1
  344. package/dist/pi/packages/ta-rooms/lib/page.d.ts +42 -4
  345. package/dist/pi/packages/ta-rooms/lib/page.js +108 -24
  346. package/dist/pi/packages/ta-rooms/lib/room-view.js +7 -3
  347. package/dist/pi/packages/ta-rooms/lib/rooms-page.js +6 -17
  348. package/dist/pi/packages/ta-rooms/lib/style.d.ts +1 -1
  349. package/dist/pi/packages/ta-rooms/lib/style.js +31 -6
  350. package/dist/pi/packages/ta-rooms/lib/tasks-view.d.ts +41 -0
  351. package/dist/pi/packages/ta-rooms/lib/tasks-view.js +228 -0
  352. package/dist/pi/packages/ta-rooms/package.json +11 -2
  353. package/dist/pi/packages/ta-rooms/web/index.js +1633 -751
  354. package/dist/pi/packages/ta-share/README.en.md +1 -1
  355. package/dist/pi/packages/ta-share/README.md +1 -1
  356. package/dist/pi/packages/ta-share/extension/index.mjs +51 -0
  357. package/dist/pi/packages/ta-share/lib/i18n.js +6 -6
  358. package/dist/pi/packages/ta-share/lib/share-dialog.js +1 -1
  359. package/dist/pi/packages/ta-share/lib/style.d.ts +1 -1
  360. package/dist/pi/packages/ta-share/lib/style.js +4 -6
  361. package/dist/pi/packages/ta-share/package.json +10 -2
  362. package/dist/pi/packages/ta-share/web/index.js +12 -14
  363. package/dist/pi/packages/ta-sync/README.en.md +55 -0
  364. package/dist/pi/packages/ta-sync/README.md +55 -0
  365. package/dist/pi/packages/ta-sync/host/index.mjs +3763 -0
  366. package/dist/pi/packages/ta-sync/lib/host.d.ts +10 -0
  367. package/dist/pi/packages/ta-sync/lib/host.js +94 -0
  368. package/dist/pi/packages/ta-sync/lib/i18n.d.ts +98 -0
  369. package/dist/pi/packages/ta-sync/lib/i18n.js +202 -0
  370. package/dist/pi/packages/ta-sync/lib/index.d.ts +7 -0
  371. package/dist/pi/packages/ta-sync/lib/index.js +115 -0
  372. package/dist/pi/packages/ta-sync/lib/migrate-archive.d.ts +88 -0
  373. package/dist/pi/packages/ta-sync/lib/migrate-archive.js +439 -0
  374. package/dist/pi/packages/ta-sync/lib/migrate-frames.d.ts +77 -0
  375. package/dist/pi/packages/ta-sync/lib/migrate-frames.js +210 -0
  376. package/dist/pi/packages/ta-sync/lib/migrate-i18n.d.ts +99 -0
  377. package/dist/pi/packages/ta-sync/lib/migrate-i18n.js +210 -0
  378. package/dist/pi/packages/ta-sync/lib/migrate-net.d.ts +51 -0
  379. package/dist/pi/packages/ta-sync/lib/migrate-net.js +170 -0
  380. package/dist/pi/packages/ta-sync/lib/migrate-protocol.d.ts +126 -0
  381. package/dist/pi/packages/ta-sync/lib/migrate-protocol.js +43 -0
  382. package/dist/pi/packages/ta-sync/lib/migrate-service.d.ts +86 -0
  383. package/dist/pi/packages/ta-sync/lib/migrate-service.js +521 -0
  384. package/dist/pi/packages/ta-sync/lib/move-panel.d.ts +16 -0
  385. package/dist/pi/packages/ta-sync/lib/move-panel.js +320 -0
  386. package/dist/pi/packages/ta-sync/lib/move-store.d.ts +15 -0
  387. package/dist/pi/packages/ta-sync/lib/move-store.js +42 -0
  388. package/dist/pi/packages/ta-sync/lib/panel.d.ts +28 -0
  389. package/dist/pi/packages/ta-sync/lib/panel.js +305 -0
  390. package/dist/pi/packages/ta-sync/lib/pictures.d.ts +22 -0
  391. package/dist/pi/packages/ta-sync/lib/pictures.js +92 -0
  392. package/dist/pi/packages/ta-sync/lib/react.d.ts +11 -0
  393. package/dist/pi/packages/ta-sync/lib/react.js +16 -0
  394. package/dist/pi/packages/ta-sync/lib/server-texts.d.ts +29 -0
  395. package/dist/pi/packages/ta-sync/lib/server-texts.js +111 -0
  396. package/dist/pi/packages/ta-sync/lib/style.d.ts +4 -0
  397. package/dist/pi/packages/ta-sync/lib/style.js +108 -0
  398. package/dist/pi/packages/ta-sync/lib/sync-codec.d.ts +16 -0
  399. package/dist/pi/packages/ta-sync/lib/sync-codec.js +61 -0
  400. package/dist/pi/packages/ta-sync/lib/sync-engine.d.ts +57 -0
  401. package/dist/pi/packages/ta-sync/lib/sync-engine.js +203 -0
  402. package/dist/pi/packages/ta-sync/lib/sync-folder.d.ts +156 -0
  403. package/dist/pi/packages/ta-sync/lib/sync-folder.js +385 -0
  404. package/dist/pi/packages/ta-sync/lib/sync-identity.d.ts +60 -0
  405. package/dist/pi/packages/ta-sync/lib/sync-identity.js +201 -0
  406. package/dist/pi/packages/ta-sync/lib/sync-items.d.ts +104 -0
  407. package/dist/pi/packages/ta-sync/lib/sync-items.js +426 -0
  408. package/dist/pi/packages/ta-sync/lib/sync-merge.d.ts +42 -0
  409. package/dist/pi/packages/ta-sync/lib/sync-merge.js +109 -0
  410. package/dist/pi/packages/ta-sync/lib/sync-protocol.d.ts +134 -0
  411. package/dist/pi/packages/ta-sync/lib/sync-protocol.js +72 -0
  412. package/dist/pi/packages/ta-sync/lib/sync-service.d.ts +128 -0
  413. package/dist/pi/packages/ta-sync/lib/sync-service.js +679 -0
  414. package/dist/pi/packages/ta-sync/lib/sync-store.d.ts +15 -0
  415. package/dist/pi/packages/ta-sync/lib/sync-store.js +41 -0
  416. package/dist/pi/packages/ta-sync/package.json +57 -0
  417. package/dist/pi/packages/ta-sync/web/index.js +2018 -0
  418. package/dist/pi/packages/ta-sync-cloud/README.en.md +31 -0
  419. package/dist/pi/packages/ta-sync-cloud/README.md +31 -0
  420. package/dist/pi/packages/ta-sync-cloud/host/index.mjs +810 -0
  421. package/dist/pi/packages/ta-sync-cloud/lib/git-store.d.ts +90 -0
  422. package/dist/pi/packages/ta-sync-cloud/lib/git-store.js +393 -0
  423. package/dist/pi/packages/ta-sync-cloud/lib/host.d.ts +13 -0
  424. package/dist/pi/packages/ta-sync-cloud/lib/host.js +112 -0
  425. package/dist/pi/packages/ta-sync-cloud/lib/s3-store.d.ts +72 -0
  426. package/dist/pi/packages/ta-sync-cloud/lib/s3-store.js +206 -0
  427. package/dist/pi/packages/ta-sync-cloud/lib/store-util.d.ts +17 -0
  428. package/dist/pi/packages/ta-sync-cloud/lib/store-util.js +69 -0
  429. package/dist/pi/packages/ta-sync-cloud/lib/webdav-store.d.ts +40 -0
  430. package/dist/pi/packages/ta-sync-cloud/lib/webdav-store.js +144 -0
  431. package/dist/pi/packages/ta-sync-cloud/package.json +63 -0
  432. package/dist/pi/packages/ta-team/README.en.md +28 -0
  433. package/dist/pi/packages/ta-team/README.md +28 -0
  434. package/dist/pi/packages/ta-team/extension/index.mjs +264 -0
  435. package/dist/pi/packages/ta-team/host/index.mjs +2100 -0
  436. package/dist/pi/packages/ta-team/lib/dialogs.d.ts +13 -0
  437. package/dist/pi/packages/ta-team/lib/dialogs.js +335 -0
  438. package/dist/pi/packages/ta-team/lib/extension.d.ts +21 -0
  439. package/dist/pi/packages/ta-team/lib/extension.js +123 -0
  440. package/dist/pi/packages/ta-team/lib/host.d.ts +13 -0
  441. package/dist/pi/packages/ta-team/lib/host.js +45 -0
  442. package/dist/pi/packages/ta-team/lib/i18n.d.ts +200 -0
  443. package/dist/pi/packages/ta-team/lib/i18n.js +401 -0
  444. package/dist/pi/packages/ta-team/lib/index.d.ts +8 -0
  445. package/dist/pi/packages/ta-team/lib/index.js +67 -0
  446. package/dist/pi/packages/ta-team/lib/join.d.ts +28 -0
  447. package/dist/pi/packages/ta-team/lib/join.js +48 -0
  448. package/dist/pi/packages/ta-team/lib/member-dialog.d.ts +2 -0
  449. package/dist/pi/packages/ta-team/lib/member-dialog.js +121 -0
  450. package/dist/pi/packages/ta-team/lib/members-tab.d.ts +11 -0
  451. package/dist/pi/packages/ta-team/lib/members-tab.js +133 -0
  452. package/dist/pi/packages/ta-team/lib/page.d.ts +42 -0
  453. package/dist/pi/packages/ta-team/lib/page.js +142 -0
  454. package/dist/pi/packages/ta-team/lib/parts.d.ts +39 -0
  455. package/dist/pi/packages/ta-team/lib/parts.js +47 -0
  456. package/dist/pi/packages/ta-team/lib/policy.d.ts +37 -0
  457. package/dist/pi/packages/ta-team/lib/policy.js +215 -0
  458. package/dist/pi/packages/ta-team/lib/protocol.d.ts +285 -0
  459. package/dist/pi/packages/ta-team/lib/protocol.js +119 -0
  460. package/dist/pi/packages/ta-team/lib/react.d.ts +8 -0
  461. package/dist/pi/packages/ta-team/lib/react.js +8 -0
  462. package/dist/pi/packages/ta-team/lib/record-tab.d.ts +8 -0
  463. package/dist/pi/packages/ta-team/lib/record-tab.js +90 -0
  464. package/dist/pi/packages/ta-team/lib/remote.d.ts +31 -0
  465. package/dist/pi/packages/ta-team/lib/remote.js +128 -0
  466. package/dist/pi/packages/ta-team/lib/roles-tab.d.ts +9 -0
  467. package/dist/pi/packages/ta-team/lib/roles-tab.js +76 -0
  468. package/dist/pi/packages/ta-team/lib/seal.d.ts +28 -0
  469. package/dist/pi/packages/ta-team/lib/seal.js +75 -0
  470. package/dist/pi/packages/ta-team/lib/shared-home.d.ts +23 -0
  471. package/dist/pi/packages/ta-team/lib/shared-home.js +123 -0
  472. package/dist/pi/packages/ta-team/lib/style.d.ts +4 -0
  473. package/dist/pi/packages/ta-team/lib/style.js +99 -0
  474. package/dist/pi/packages/ta-team/lib/team-admin.d.ts +31 -0
  475. package/dist/pi/packages/ta-team/lib/team-admin.js +140 -0
  476. package/dist/pi/packages/ta-team/lib/team-audit.d.ts +35 -0
  477. package/dist/pi/packages/ta-team/lib/team-audit.js +152 -0
  478. package/dist/pi/packages/ta-team/lib/team-core.d.ts +58 -0
  479. package/dist/pi/packages/ta-team/lib/team-core.js +115 -0
  480. package/dist/pi/packages/ta-team/lib/team-error.d.ts +4 -0
  481. package/dist/pi/packages/ta-team/lib/team-error.js +8 -0
  482. package/dist/pi/packages/ta-team/lib/team-expiry.d.ts +15 -0
  483. package/dist/pi/packages/ta-team/lib/team-expiry.js +67 -0
  484. package/dist/pi/packages/ta-team/lib/team-files.d.ts +21 -0
  485. package/dist/pi/packages/ta-team/lib/team-files.js +119 -0
  486. package/dist/pi/packages/ta-team/lib/team-inbox.d.ts +8 -0
  487. package/dist/pi/packages/ta-team/lib/team-inbox.js +32 -0
  488. package/dist/pi/packages/ta-team/lib/team-invites.d.ts +46 -0
  489. package/dist/pi/packages/ta-team/lib/team-invites.js +204 -0
  490. package/dist/pi/packages/ta-team/lib/team-page.d.ts +6 -0
  491. package/dist/pi/packages/ta-team/lib/team-page.js +41 -0
  492. package/dist/pi/packages/ta-team/lib/team-paths.d.ts +15 -0
  493. package/dist/pi/packages/ta-team/lib/team-paths.js +70 -0
  494. package/dist/pi/packages/ta-team/lib/team-people.d.ts +28 -0
  495. package/dist/pi/packages/ta-team/lib/team-people.js +106 -0
  496. package/dist/pi/packages/ta-team/lib/team-requests.d.ts +24 -0
  497. package/dist/pi/packages/ta-team/lib/team-requests.js +126 -0
  498. package/dist/pi/packages/ta-team/lib/team-runs.d.ts +38 -0
  499. package/dist/pi/packages/ta-team/lib/team-runs.js +136 -0
  500. package/dist/pi/packages/ta-team/lib/team-service.d.ts +32 -0
  501. package/dist/pi/packages/ta-team/lib/team-service.js +58 -0
  502. package/dist/pi/packages/ta-team/lib/team-shares.d.ts +52 -0
  503. package/dist/pi/packages/ta-team/lib/team-shares.js +145 -0
  504. package/dist/pi/packages/ta-team/lib/team-waits.d.ts +8 -0
  505. package/dist/pi/packages/ta-team/lib/team-waits.js +42 -0
  506. package/dist/pi/packages/ta-team/lib/team-watch.d.ts +28 -0
  507. package/dist/pi/packages/ta-team/lib/team-watch.js +136 -0
  508. package/dist/pi/packages/ta-team/package.json +68 -0
  509. package/dist/pi/packages/ta-team/web/index.js +2741 -0
  510. package/dist/pi/packages/ta-workspace/package.json +1 -1
  511. package/dist/pi/packages/ta-workspace/web/index.js +157 -0
  512. package/dist/public/assets/{abnfDiagram-S7VZAUFO-BnqtcbpZ.js → abnfDiagram-S7VZAUFO-DJMZKA5d.js} +1 -1
  513. package/dist/public/assets/{architecture-WOLXFQ4H-BzPq1Ioe.js → architecture-WOLXFQ4H-DwZ8A2Bp.js} +1 -1
  514. package/dist/public/assets/{architectureDiagram-YGSQEFNW-BsquO3a7.js → architectureDiagram-YGSQEFNW-DPezb7-w.js} +1 -1
  515. package/dist/public/assets/{blockDiagram-APKKGZFW-BQNYOEP4.js → blockDiagram-APKKGZFW-SrFYBlSp.js} +1 -1
  516. package/dist/public/assets/{browser-DS711n7Y.js → browser-CljOqDFz.js} +1 -1
  517. package/dist/public/assets/{c4Diagram-KJ2TOQU5-D6e79Ycq.js → c4Diagram-KJ2TOQU5-COCMkiJ6.js} +1 -1
  518. package/dist/public/assets/{chunk-6MUBBAK2-B-sgaPoU.js → chunk-6MUBBAK2-CWRxZCiu.js} +1 -1
  519. package/dist/public/assets/{chunk-AXFCVDMN-D8pJKIg2.js → chunk-AXFCVDMN-Dgn3RHlx.js} +1 -1
  520. package/dist/public/assets/{chunk-BG4553SI-86TL-vCz.js → chunk-BG4553SI-BDnAChfb.js} +1 -1
  521. package/dist/public/assets/{chunk-DQASFODM-CfUVuGjc.js → chunk-DQASFODM-DSgprMfc.js} +1 -1
  522. package/dist/public/assets/{chunk-HFQBQIA3-Drm0FEYk.js → chunk-HFQBQIA3-ChtjyKjP.js} +1 -1
  523. package/dist/public/assets/{chunk-KQLB2F66-BVFRADlC.js → chunk-KQLB2F66-B2o0ufJC.js} +1 -1
  524. package/dist/public/assets/{chunk-KS47KZWR-DfyALEmP.js → chunk-KS47KZWR-C4qJvDaX.js} +1 -1
  525. package/dist/public/assets/{chunk-LEVMRMFU-DtJVzk2c.js → chunk-LEVMRMFU-2jTGUstS.js} +1 -1
  526. package/dist/public/assets/{chunk-M57EVK23-DTy27PHQ.js → chunk-M57EVK23-CKAWW7fj.js} +1 -1
  527. package/dist/public/assets/{chunk-OY52VR5R-nSgn7jZg.js → chunk-OY52VR5R-B5TUKZAt.js} +1 -1
  528. package/dist/public/assets/{chunk-QB3YPZ4I-CkSxO_X6.js → chunk-QB3YPZ4I-CyQFTqwG.js} +1 -1
  529. package/dist/public/assets/{chunk-R3KSYZAL-Ck6iAjAL.js → chunk-R3KSYZAL-C6git_yh.js} +1 -1
  530. package/dist/public/assets/{chunk-STOXU5M4-DQPHdSTh.js → chunk-STOXU5M4-AwEqcNnS.js} +1 -1
  531. package/dist/public/assets/{chunk-TU62E6Q5-Bc2AbV2Y.js → chunk-TU62E6Q5-GKcRDmvw.js} +1 -1
  532. package/dist/public/assets/{chunk-X4PVCEUW-Cgpm0IXm.js → chunk-X4PVCEUW-CMG5EfZ9.js} +1 -1
  533. package/dist/public/assets/{chunk-XXDRQBXY-CGE4eLpg.js → chunk-XXDRQBXY-BHd-dKtZ.js} +1 -1
  534. package/dist/public/assets/{classDiagram-v2-L25IHNXF-4eQuDPEo.js → classDiagram-v2-L25IHNXF-HaRsBCG9.js} +1 -1
  535. package/dist/public/assets/{cose-bilkent-JH36ORCC-tDLCWq07.js → cose-bilkent-JH36ORCC-BPBTCfj3.js} +1 -1
  536. package/dist/public/assets/cynefin-EF2NZ3EQ-DyqqRII3.js +1 -0
  537. package/dist/public/assets/{cynefinDiagram-L36ESFBY-ByqcZ8x9.js → cynefinDiagram-L36ESFBY-dAmWDtva.js} +1 -1
  538. package/dist/public/assets/{d3-selection-Bgn1374-.js → d3-selection-BhemR5ul.js} +1 -1
  539. package/dist/public/assets/{dagre-SPEB5RXH-mCgr71mV.js → dagre-SPEB5RXH-D93g6hNI.js} +1 -1
  540. package/dist/public/assets/{diagram-3B7GL73J-DpYSwpQ0.js → diagram-3B7GL73J-FJBKgG3X.js} +1 -1
  541. package/dist/public/assets/{diagram-DNEMPZML-DMozUQzi.js → diagram-DNEMPZML-BP22T976.js} +1 -1
  542. package/dist/public/assets/{diagram-L3MUGCDN-Bk5Uf8PD.js → diagram-L3MUGCDN-DcrCJXRt.js} +1 -1
  543. package/dist/public/assets/{diagram-LA4NIPWU-DFt5cPVK.js → diagram-LA4NIPWU-DUgd3PHQ.js} +1 -1
  544. package/dist/public/assets/{diagram-MHCOC4E2-BkZZcKqK.js → diagram-MHCOC4E2-ejTInqzQ.js} +1 -1
  545. package/dist/public/assets/{diagram-XPFHEONP-HEY6kyyN.js → diagram-XPFHEONP-BLjkgho1.js} +1 -1
  546. package/dist/public/assets/{dist-Bj2CrKn7.js → dist-C9xqTt0E.js} +1 -1
  547. package/dist/public/assets/{ebnfDiagram-UZSYDL2S-D4JvYyVb.js → ebnfDiagram-UZSYDL2S-CB1QQ4_T.js} +1 -1
  548. package/dist/public/assets/{editor.api-BpJFzYbl.js → editor.api-lz6I1oVk.js} +1 -1
  549. package/dist/public/assets/{elk-XV6XMXQE-CT6qLJkF.js → elk-XV6XMXQE-CLBx1s2b.js} +1 -1
  550. package/dist/public/assets/{erDiagram-EYBAPDEH-BGng1goR.js → erDiagram-EYBAPDEH-Dsj6RYi5.js} +1 -1
  551. package/dist/public/assets/{eventmodeling-K75KTNOO-Tt8O-Q1Z.js → eventmodeling-K75KTNOO-smOORsSG.js} +1 -1
  552. package/dist/public/assets/flowDiagram-MALGAFMO-DFmQPJ7B.js +1 -0
  553. package/dist/public/assets/{freemarker2-Dd5ksoRn.js → freemarker2-DrLPw7Mc.js} +1 -1
  554. package/dist/public/assets/{ganttDiagram-23REXITY-Jl8VO_g2.js → ganttDiagram-23REXITY-BV9WK0rK.js} +1 -1
  555. package/dist/public/assets/gitGraph-VSP46ZUC-ybrJCK6u.js +1 -0
  556. package/dist/public/assets/{gitGraphDiagram-STJD7YCW-Be4qXALb.js → gitGraphDiagram-STJD7YCW-CsSpSQ0T.js} +1 -1
  557. package/dist/public/assets/{handlebars-4xabgUi4.js → handlebars-CLx5-csF.js} +1 -1
  558. package/dist/public/assets/{html-Dk3kt2w_.js → html-C9LmGm46.js} +1 -1
  559. package/dist/public/assets/{index-Bx0c7eoh.js → index-CLWW0mVu.js} +2 -2
  560. package/dist/public/assets/info-OHQRW6UA-n41_wZE4.js +1 -0
  561. package/dist/public/assets/{infoDiagram-KBXO4MBG-Coc0tdwb.js → infoDiagram-KBXO4MBG-wm5AnXDz.js} +1 -1
  562. package/dist/public/assets/{ishikawaDiagram-M35NCXHK-CE_1VQCg.js → ishikawaDiagram-M35NCXHK-BLUBDeS3.js} +1 -1
  563. package/dist/public/assets/{javascript-DKLGqy6v.js → javascript-C4S1eQb7.js} +1 -1
  564. package/dist/public/assets/{journeyDiagram-OPLOXDXO-CrolRZ_7.js → journeyDiagram-OPLOXDXO-DXc7-I_g.js} +1 -1
  565. package/dist/public/assets/{jsonMode-Chcs19_y.js → jsonMode-lLJKR2M6.js} +1 -1
  566. package/dist/public/assets/{kanban-definition-BZKZHSQY-CjJj47De.js → kanban-definition-BZKZHSQY-D5Ra4L_5.js} +1 -1
  567. package/dist/public/assets/{liquid-jff3p-Ji.js → liquid-DRlm-XZd.js} +1 -1
  568. package/dist/public/assets/{mdx-DW4uRDfJ.js → mdx-CzIqeqPy.js} +1 -1
  569. package/dist/public/assets/{mermaid-parser.core-XhQj6FvH.js → mermaid-parser.core-BIPB1BgS.js} +3 -3
  570. package/dist/public/assets/{mermaid.core-OD4Atimg.js → mermaid.core-DxBlQ6oF.js} +4 -4
  571. package/dist/public/assets/{mindmap-definition-I2QAS2VK-DpGelVY7.js → mindmap-definition-I2QAS2VK-BdupvuYr.js} +1 -1
  572. package/dist/public/assets/module-BPxWyxwR.js +2362 -0
  573. package/dist/public/assets/module-C_MSCGQC.js +1 -0
  574. package/dist/public/assets/{monaco-BTVZP-tU.js → monaco-ChpJIYsY.js} +3 -3
  575. package/dist/public/assets/packet-JDAUHWVQ-BjrqMgis.js +1 -0
  576. package/dist/public/assets/{pegDiagram-FD4XPPHP-CqcBmPfB.js → pegDiagram-FD4XPPHP-C_GF7Fng.js} +1 -1
  577. package/dist/public/assets/pie-XZMESJXO-CJSA88kr.js +1 -0
  578. package/dist/public/assets/{pieDiagram-J4AKIIQI-CRir3beB.js → pieDiagram-J4AKIIQI-WlpNP-IM.js} +1 -1
  579. package/dist/public/assets/{python-BwW_0207.js → python-BJgFCfc8.js} +1 -1
  580. package/dist/public/assets/{quadrantDiagram-XTYBLID2-DIY6gdcf.js → quadrantDiagram-XTYBLID2-CkCL5rJY.js} +1 -1
  581. package/dist/public/assets/radar-ABXABTNO-4nLUXAkG.js +1 -0
  582. package/dist/public/assets/railroad-I3PHUGI6-BD2LqZSr.js +1 -0
  583. package/dist/public/assets/{railroad-abnf-LNEFI6M7-XWNOzunl.js → railroad-abnf-LNEFI6M7-DZZKUytl.js} +1 -1
  584. package/dist/public/assets/{railroad-ebnf-DWYD2UWJ-CI0-j1Jz.js → railroad-ebnf-DWYD2UWJ-CS7KsJdb.js} +1 -1
  585. package/dist/public/assets/{railroad-peg-JR7BVNR7-BVB_IaIG.js → railroad-peg-JR7BVNR7-CiukTZVd.js} +1 -1
  586. package/dist/public/assets/{railroadDiagram-MRQ6NCDL-CudwT6q2.js → railroadDiagram-MRQ6NCDL-BS0R_H3-.js} +1 -1
  587. package/dist/public/assets/{razor-DrjCyQqB.js → razor-jcBIjr45.js} +1 -1
  588. package/dist/public/assets/{requirementDiagram-Y7LWUY3S-CvRMeRqj.js → requirementDiagram-Y7LWUY3S-C0_T9jgl.js} +1 -1
  589. package/dist/public/assets/{sankeyDiagram-WGJFYUXA-adxYCJKr.js → sankeyDiagram-WGJFYUXA-DF15sUfS.js} +1 -1
  590. package/dist/public/assets/{sequenceDiagram-5NDRBG5M-lCRsoLUp.js → sequenceDiagram-5NDRBG5M-7AkTLleX.js} +1 -1
  591. package/dist/public/assets/{stateDiagram-v2-FJ4FJNEA-DNst1BLg.js → stateDiagram-v2-FJ4FJNEA-CU3i-U9q.js} +1 -1
  592. package/dist/public/assets/{swimlanes-UMQ2AFYF-S_omrdvA.js → swimlanes-UMQ2AFYF-CR-ieLeo.js} +1 -1
  593. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-COK2pFDF.js +8 -0
  594. package/dist/public/assets/{timeline-definition-SEUHKTQE-_pMGrTE-.js → timeline-definition-SEUHKTQE-DeM0Uekm.js} +1 -1
  595. package/dist/public/assets/treeView-D4JQ5SDB-BL13z_2J.js +1 -0
  596. package/dist/public/assets/treemap-SAJKECNS-Lx2qjQpO.js +1 -0
  597. package/dist/public/assets/{typescript-0-z_OYCU.js → typescript-B7zp7QPf.js} +1 -1
  598. package/dist/public/assets/{usecaseDiagram-AFA6YXN4-B2oJKi5Q.js → usecaseDiagram-AFA6YXN4-D6rDIgdU.js} +1 -1
  599. package/dist/public/assets/{vennDiagram-NNMJR3RB-inPs2Kkr.js → vennDiagram-NNMJR3RB-CncVDcMl.js} +1 -1
  600. package/dist/public/assets/wardley-7MLQ67FV-B4j5rilS.js +1 -0
  601. package/dist/public/assets/{wardleyDiagram-S7YFUSEH-DNhNHM7b.js → wardleyDiagram-S7YFUSEH-DKPAMfTE.js} +1 -1
  602. package/dist/public/assets/{xml-BXPxQzKF.js → xml-BJIgLD52.js} +1 -1
  603. package/dist/public/assets/{xychartDiagram-GGNKY7IX-DJc93dNT.js → xychartDiagram-GGNKY7IX-DmmXGebm.js} +1 -1
  604. package/dist/public/assets/{yaml-CGmD9Rya.js → yaml-Dxb2gmP5.js} +1 -1
  605. package/dist/public/index.html +1 -1
  606. package/dist/serve/index.mjs +7727 -3847
  607. package/package.json +37 -31
  608. package/dist/pi/packages/ta-cron/lib/composer.d.ts +0 -11
  609. package/dist/pi/packages/ta-cron/lib/composer.js +0 -58
  610. package/dist/pi/packages/ta-extensions/lib/composer.d.ts +0 -17
  611. package/dist/pi/packages/ta-extensions/lib/composer.js +0 -84
  612. package/dist/pi/packages/ta-recall/lib/skill-card.d.ts +0 -9
  613. package/dist/pi/packages/ta-recall/lib/skill-card.js +0 -51
  614. package/dist/pi/packages/ta-recall/lib/skill-util.d.ts +0 -19
  615. package/dist/pi/packages/ta-recall/lib/skill-util.js +0 -110
  616. package/dist/public/assets/cynefin-EF2NZ3EQ-Dd40W2Jh.js +0 -1
  617. package/dist/public/assets/flowDiagram-MALGAFMO-uFzenfA3.js +0 -1
  618. package/dist/public/assets/gitGraph-VSP46ZUC-D28I_jUc.js +0 -1
  619. package/dist/public/assets/info-OHQRW6UA-5vIGEIq7.js +0 -1
  620. package/dist/public/assets/module-CrD0OHQp.js +0 -1
  621. package/dist/public/assets/module-DEBMgdtf.js +0 -2273
  622. package/dist/public/assets/packet-JDAUHWVQ-CBxQ5Mzy.js +0 -1
  623. package/dist/public/assets/pie-XZMESJXO-DT5V3581.js +0 -1
  624. package/dist/public/assets/radar-ABXABTNO-BAOovYEa.js +0 -1
  625. package/dist/public/assets/railroad-I3PHUGI6-RZ2Rnwzh.js +0 -1
  626. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-By5lnz4u.js +0 -8
  627. package/dist/public/assets/treeView-D4JQ5SDB-Cyb9N8KY.js +0 -1
  628. package/dist/public/assets/treemap-SAJKECNS-BkMo57pG.js +0 -1
  629. package/dist/public/assets/wardley-7MLQ67FV-CSt-uQ-Y.js +0 -1
@@ -0,0 +1,1859 @@
1
+ // web-src/nearby-service.ts
2
+ import { randomBytes as randomBytes3 } from "node:crypto";
3
+
4
+ // ../ta-relay/esm/common/relay-faces.js
5
+ var FACE_COUNT = 16;
6
+ var BLUE = "#4285F4";
7
+ var RED = "#EA4335";
8
+ var YELLOW = "#FBBC05";
9
+ var GREEN = "#34A853";
10
+ var MINT = "#5CC27F";
11
+ var ORANGE = "#EE7B3B";
12
+ var VIOLET = "#8C5CF0";
13
+ var CREAM = "#F1DFC0";
14
+ var TEAL = "#26B0A9";
15
+ var PINK = "#F27BA6";
16
+ var LILAC = "#B49CF5";
17
+ var SKY = "#45B5E8";
18
+ var INDIGO = "#5C6BC0";
19
+ var MIST = "#DCE3F0";
20
+ var INK = "#202124";
21
+ var WHITE = "#FFFFFF";
22
+ var CHEEK = "rgba(255, 160, 185, 0.55)";
23
+ var EDGE = "rgba(0, 0, 0, 0.14)";
24
+ var CHEEK_DEEP = "rgba(120, 10, 30, 0.35)";
25
+ var CHEEK_WARM = "rgba(234, 67, 53, 0.4)";
26
+ var LOOKS = [
27
+ { color: MINT, eye: "#1D3B27", cheek: CHEEK, eyeY: 21, gap: 8 },
28
+ { color: BLUE, eye: WHITE, cheek: CHEEK, eyeY: 23, gap: 8 },
29
+ { color: RED, eye: WHITE, cheek: CHEEK_DEEP, eyeY: 22, gap: 8 },
30
+ { color: CREAM, eye: "#4A3420", cheek: "rgba(240, 120, 120, 0.5)", accent: "#DDBF8E", eyeY: 22, gap: 7.6 },
31
+ { color: GREEN, eye: WHITE, cheek: CHEEK, eyeY: 19, gap: 7.2 },
32
+ { color: INDIGO, eye: WHITE, cheek: CHEEK, eyeY: 20, gap: 7.4 },
33
+ { color: YELLOW, eye: INK, cheek: CHEEK_WARM, accent: "#F29900", eyeY: 24, gap: 8.4 },
34
+ { color: VIOLET, eye: "#22134A", cheek: CHEEK, eyeY: 20, gap: 8 },
35
+ { color: MIST, eye: "#2B3245", cheek: CHEEK, eyeY: 19, gap: 7.6 },
36
+ { color: SKY, eye: WHITE, cheek: CHEEK, eyeY: 21, gap: 6.4 },
37
+ { color: ORANGE, eye: "#3D1C08", cheek: CHEEK, accent: GREEN, eyeY: 22, gap: 8.6, brows: true },
38
+ { color: WHITE, eye: WHITE, cheek: CHEEK, accent: INK, mouth: INK, eyeY: 22, gap: 10 },
39
+ { color: TEAL, eye: WHITE, cheek: CHEEK, accent: "#1B8A84", eyeY: 22.5, gap: 8.4 },
40
+ { color: PINK, eye: "#4A1428", cheek: "rgba(160, 20, 70, 0.3)", eyeY: 24, gap: 7.4 },
41
+ { color: LILAC, eye: "#2A1A5E", cheek: CHEEK, eyeY: 25, gap: 8 },
42
+ { color: YELLOW, eye: INK, cheek: CHEEK_WARM, eyeY: 25, gap: 7.4 }
43
+ ];
44
+ function corners(count, radius, cx, cy, inner) {
45
+ const points = [];
46
+ const steps = inner ? count * 2 : count;
47
+ for (let index = 0;index < steps; index++) {
48
+ const r = inner && index % 2 === 1 ? inner : radius;
49
+ const angle = -Math.PI / 2 + index * 2 * Math.PI / steps;
50
+ points.push(`${(cx + r * Math.cos(angle)).toFixed(2)},${(cy + r * Math.sin(angle)).toFixed(2)}`);
51
+ }
52
+ return points.join(" ");
53
+ }
54
+ var PENTAGON = corners(5, 13.5, 20, 21.5);
55
+ var HEXAGON = corners(6, 14, 20, 20);
56
+ var STAR = corners(5, 15.5, 20, 21.5, 8.6);
57
+ function node(tag, attrs, children) {
58
+ return children ? { tag, attrs, children } : { tag, attrs };
59
+ }
60
+ function rounded(points, color, width = 5) {
61
+ return node("polygon", { points, fill: color, stroke: color, "stroke-width": width, "stroke-linejoin": "round" });
62
+ }
63
+ function shape(face, look) {
64
+ const { color, accent = color } = look;
65
+ switch (face) {
66
+ case 1:
67
+ return node("g", {}, [
68
+ rounded("7.5,6.5 17,12 8.5,18", color, 4),
69
+ rounded("32.5,6.5 23,12 31.5,18", color, 4),
70
+ node("ellipse", { cx: 20, cy: 23, rx: 14.5, ry: 12.5, fill: color })
71
+ ]);
72
+ case 2:
73
+ return rounded(PENTAGON, color);
74
+ case 3:
75
+ return node("g", {}, [
76
+ node("circle", { cx: 9.5, cy: 10.5, r: 5.5, fill: color }),
77
+ node("circle", { cx: 30.5, cy: 10.5, r: 5.5, fill: color }),
78
+ node("circle", { cx: 9.5, cy: 10.5, r: 2.6, fill: accent }),
79
+ node("circle", { cx: 30.5, cy: 10.5, r: 2.6, fill: accent }),
80
+ node("ellipse", { cx: 20, cy: 22.5, rx: 14.5, ry: 13, fill: color })
81
+ ]);
82
+ case 4:
83
+ return node("rect", { x: 8.5, y: 4, width: 23, height: 32, rx: 11.5, fill: color });
84
+ case 5:
85
+ return rounded("20,5.5 34.5,20 20,34.5 5.5,20", color, 5.5);
86
+ case 6:
87
+ return node("g", {}, [
88
+ node("ellipse", { cx: 20, cy: 11, rx: 3.2, ry: 3.6, fill: accent }),
89
+ node("path", { d: "M20 12.5c9.2 0 15.5 5.6 15.5 12.4 0 6.4-6.9 10.1-15.5 10.1S4.5 31.3 4.5 24.9C4.5 18.1 10.8 12.5 20 12.5Z", fill: color })
90
+ ]);
91
+ case 7:
92
+ return rounded(HEXAGON, color);
93
+ case 8:
94
+ return node("path", {
95
+ d: "M8 19a12 12 0 0 1 24 0v14l-4-3-4 3-4-3-4 3-4-3-4 3Z",
96
+ fill: color,
97
+ stroke: EDGE,
98
+ "stroke-width": 0.8,
99
+ "stroke-linejoin": "round"
100
+ });
101
+ case 9:
102
+ return rounded(STAR, color, 4.5);
103
+ case 10:
104
+ return node("g", {}, [
105
+ node("rect", { x: 18.6, y: 4.5, width: 2.8, height: 7, rx: 1.4, fill: accent }),
106
+ node("ellipse", { cx: 12.5, cy: 23, rx: 8.5, ry: 11, fill: color }),
107
+ node("ellipse", { cx: 27.5, cy: 23, rx: 8.5, ry: 11, fill: color }),
108
+ node("ellipse", { cx: 20, cy: 22.5, rx: 9.5, ry: 12, fill: color })
109
+ ]);
110
+ case 11:
111
+ return node("g", {}, [
112
+ node("circle", { cx: 9.5, cy: 10, r: 5, fill: accent }),
113
+ node("circle", { cx: 30.5, cy: 10, r: 5, fill: accent }),
114
+ node("ellipse", { cx: 20, cy: 22.5, rx: 14.5, ry: 13, fill: color, stroke: EDGE, "stroke-width": 0.8 }),
115
+ node("ellipse", { cx: 14.6, cy: 22, rx: 3.6, ry: 4.4, transform: "rotate(20 14.6 22)", fill: accent }),
116
+ node("ellipse", { cx: 25.4, cy: 22, rx: 3.6, ry: 4.4, transform: "rotate(-20 25.4 22)", fill: accent })
117
+ ]);
118
+ case 12:
119
+ return node("g", {}, [
120
+ node("rect", { x: 19.1, y: 6, width: 1.8, height: 7, fill: accent }),
121
+ node("circle", { cx: 20, cy: 5, r: 2.2, fill: accent }),
122
+ node("rect", { x: 5.5, y: 12, width: 29, height: 22.5, rx: 6.5, fill: color })
123
+ ]);
124
+ case 13:
125
+ return node("path", { d: "M20 4.5c2 0 13 11.6 13 20.2 0 6.4-5.8 10.8-13 10.8S7 31.1 7 24.7C7 16.1 18 4.5 20 4.5Z", fill: color });
126
+ case 14:
127
+ return node("g", {}, [
128
+ node("ellipse", { cx: 14, cy: 10.5, rx: 3.6, ry: 8, transform: "rotate(-8 14 10.5)", fill: color }),
129
+ node("ellipse", { cx: 26, cy: 10.5, rx: 3.6, ry: 8, transform: "rotate(8 26 10.5)", fill: color }),
130
+ node("ellipse", { cx: 20, cy: 25, rx: 14, ry: 11, fill: color })
131
+ ]);
132
+ case 15:
133
+ return rounded("20,7 35,33 5,33", color, 6);
134
+ default:
135
+ return node("circle", { cx: 20, cy: 21, r: 14.5, fill: color });
136
+ }
137
+ }
138
+ var FaceUtil;
139
+ (function(FaceUtil2) {
140
+ function of(seed) {
141
+ let hash = 0;
142
+ for (const char of seed) {
143
+ hash = hash * 31 + char.charCodeAt(0) | 0;
144
+ }
145
+ return Math.abs(hash) % FACE_COUNT;
146
+ }
147
+ FaceUtil2.of = of;
148
+ function pick(face, seed = "") {
149
+ return face !== undefined && face >= 0 && face < FACE_COUNT ? Math.floor(face) : of(seed);
150
+ }
151
+ FaceUtil2.pick = pick;
152
+ function color(face) {
153
+ var _a;
154
+ return ((_a = LOOKS[face]) !== null && _a !== undefined ? _a : LOOKS[0]).color;
155
+ }
156
+ FaceUtil2.color = color;
157
+ function art(face) {
158
+ var _a, _b;
159
+ const look = (_a = LOOKS[face]) !== null && _a !== undefined ? _a : LOOKS[0];
160
+ const half = look.gap / 2;
161
+ const eyeW = 4.1;
162
+ const eyeH = 4.9;
163
+ const top = look.eyeY - eyeH / 2;
164
+ const cheekY = look.eyeY + 3.6;
165
+ const cheekX = half + 2.2;
166
+ const mouthY = look.eyeY + 3.4;
167
+ const features = [
168
+ node("g", { fill: look.cheek }, [
169
+ node("ellipse", { cx: 20 - cheekX, cy: cheekY, rx: 2.2, ry: 1.25 }),
170
+ node("ellipse", { cx: 20 + cheekX, cy: cheekY, rx: 2.2, ry: 1.25 })
171
+ ])
172
+ ];
173
+ if (look.brows) {
174
+ features.push(node("path", {
175
+ d: `M${20 - half - 3.4} ${top - 2.6}l3.6 1.6M${20 + half + 3.4} ${top - 2.6}l-3.6 1.6`,
176
+ stroke: look.eye,
177
+ "stroke-width": 1.4,
178
+ "stroke-linecap": "round",
179
+ fill: "none"
180
+ }));
181
+ }
182
+ features.push(node("g", { class: "ta-face-eyes", fill: look.eye }, [
183
+ node("rect", { x: 20 - half - eyeW / 2, y: top, width: eyeW, height: eyeH, rx: eyeW / 2 }),
184
+ node("rect", { x: 20 + half - eyeW / 2, y: top, width: eyeW, height: eyeH, rx: eyeW / 2 })
185
+ ]), node("path", {
186
+ d: `M18.1 ${mouthY}q.95 1.25 1.9 0q.95 1.25 1.9 0`,
187
+ fill: "none",
188
+ stroke: (_b = look.mouth) !== null && _b !== undefined ? _b : look.eye,
189
+ "stroke-width": 1.1,
190
+ "stroke-linecap": "round",
191
+ "stroke-linejoin": "round"
192
+ }));
193
+ return node("g", { class: "ta-face-body" }, [shape(face, look), node("g", { class: "ta-face-look" }, features)]);
194
+ }
195
+ FaceUtil2.art = art;
196
+ })(FaceUtil || (FaceUtil = {}));
197
+
198
+ // web-src/nearby-crypto.ts
199
+ import { createCipheriv, createDecipheriv, createECDH, createHmac, hkdfSync, randomBytes } from "node:crypto";
200
+ var SLOT_MS = 15 * 60000;
201
+
202
+ class NearbyKeys {
203
+ createdAt;
204
+ e;
205
+ x;
206
+ ecdh;
207
+ constructor(createdAt = Date.now()) {
208
+ this.createdAt = createdAt;
209
+ this.e = randomBytes(9).toString("base64url");
210
+ this.ecdh = createECDH("prime256v1");
211
+ this.x = this.ecdh.generateKeys().toString("base64url");
212
+ }
213
+ keyWith(e, x) {
214
+ const secret = this.ecdh.computeSecret(Buffer.from(x, "base64url"));
215
+ return Buffer.from(hkdfSync("sha256", secret, [this.e, e].sort().join("."), "ta-near/1 seal", 32));
216
+ }
217
+ }
218
+ var NearbyCrypto;
219
+ ((NearbyCrypto) => {
220
+ function slot(now = Date.now()) {
221
+ return Math.floor(now / SLOT_MS);
222
+ }
223
+ NearbyCrypto.slot = slot;
224
+ function mark(identity, slot2) {
225
+ return createHmac("sha256", identity).update(`ta-near/1 ${slot2}`).digest().subarray(0, 12).toString("base64url");
226
+ }
227
+ NearbyCrypto.mark = mark;
228
+ function marks(identity, mark2, now = Date.now()) {
229
+ const at = slot(now);
230
+ return NearbyCrypto.mark(identity, at) === mark2 || NearbyCrypto.mark(identity, at - 1) === mark2;
231
+ }
232
+ NearbyCrypto.marks = marks;
233
+ function seal(key, value) {
234
+ const iv = randomBytes(12);
235
+ const cipher = createCipheriv("aes-256-gcm", key, iv);
236
+ const body = Buffer.concat([cipher.update(JSON.stringify(value), "utf8"), cipher.final(), cipher.getAuthTag()]);
237
+ return { i: iv.toString("base64url"), c: body.toString("base64url") };
238
+ }
239
+ NearbyCrypto.seal = seal;
240
+ function open(key, sealed) {
241
+ const body = Buffer.from(sealed.c, "base64url");
242
+ if (body.length < 16) {
243
+ throw new Error("Too short.");
244
+ }
245
+ const decipher = createDecipheriv("aes-256-gcm", key, Buffer.from(sealed.i, "base64url"));
246
+ decipher.setAuthTag(body.subarray(body.length - 16));
247
+ return JSON.parse(Buffer.concat([decipher.update(body.subarray(0, body.length - 16)), decipher.final()]).toString("utf8"));
248
+ }
249
+ NearbyCrypto.open = open;
250
+ })(NearbyCrypto ||= {});
251
+
252
+ // web-src/nearby-meet.ts
253
+ import { createHash } from "node:crypto";
254
+ var NearbyMeetUtil;
255
+ ((NearbyMeetUtil) => {
256
+ const TEXT = 200;
257
+ const ITEM = 40;
258
+ function card(value) {
259
+ const data = value && typeof value === "object" ? value : undefined;
260
+ if (!data) {
261
+ return;
262
+ }
263
+ const list = (items, max) => [
264
+ ...new Set((Array.isArray(items) ? items : typeof items === "string" ? items.split(/[,,、;\n]/) : []).filter((item) => typeof item === "string").map((item) => item.replace(/\s+/g, " ").trim().slice(0, ITEM)).filter(Boolean))
265
+ ].slice(0, max);
266
+ const card2 = {
267
+ line: typeof data.line === "string" ? data.line.replace(/\s+/g, " ").trim().slice(0, TEXT) : "",
268
+ topics: list(data.topics, 8),
269
+ seeking: list(data.seeking, 3),
270
+ offering: list(data.offering, 3)
271
+ };
272
+ return card2.line || card2.topics.length || card2.seeking.length || card2.offering.length ? card2 : undefined;
273
+ }
274
+ NearbyMeetUtil.card = card;
275
+ function key(card2) {
276
+ return createHash("sha256").update(JSON.stringify([card2.line, card2.topics, card2.seeking, card2.offering])).digest().subarray(0, 9).toString("base64url");
277
+ }
278
+ NearbyMeetUtil.key = key;
279
+ function normal(text) {
280
+ return text.toLowerCase().replace(/[\s\p{P}]+/gu, " ").trim();
281
+ }
282
+ function grams(text) {
283
+ const words = normal(text).split(" ").filter(Boolean);
284
+ const grams2 = new Set;
285
+ for (const word of words) {
286
+ if (/^[\p{Script=Latin}\d]+$/u.test(word)) {
287
+ if (word.length > 1) {
288
+ grams2.add(word);
289
+ }
290
+ } else {
291
+ for (let i = 0;i < word.length - 1; i++) {
292
+ grams2.add(word.slice(i, i + 2));
293
+ }
294
+ }
295
+ }
296
+ return grams2;
297
+ }
298
+ function same(a, b) {
299
+ const x = normal(a);
300
+ const y = normal(b);
301
+ if (!x || !y) {
302
+ return false;
303
+ }
304
+ if (x.length >= 2 && y.includes(x) || y.length >= 2 && x.includes(y)) {
305
+ return true;
306
+ }
307
+ const gx = grams(x);
308
+ const gy = grams(y);
309
+ const shared = [...gx].filter((gram) => gy.has(gram)).length;
310
+ return shared > 0 && shared / Math.min(gx.size, gy.size) >= 0.5;
311
+ }
312
+ NearbyMeetUtil.same = same;
313
+ function reason(mine, theirs) {
314
+ for (const seeking of mine.seeking) {
315
+ const offered = theirs.offering.filter((item) => same(seeking, item));
316
+ const helps = offered.length ? offered : theirs.topics.filter((item) => same(seeking, item));
317
+ if (helps.length) {
318
+ return { kind: "helps", what: helps.slice(0, 2), seeking };
319
+ }
320
+ }
321
+ const both = theirs.topics.filter((topic) => mine.topics.some((other) => same(topic, other)));
322
+ return both.length >= 2 ? { kind: "topics", what: both.slice(0, 3) } : undefined;
323
+ }
324
+ NearbyMeetUtil.reason = reason;
325
+ })(NearbyMeetUtil ||= {});
326
+
327
+ // web-src/nearby-net.ts
328
+ import { createSocket } from "node:dgram";
329
+ import { createConnection, createServer } from "node:net";
330
+ import { networkInterfaces } from "node:os";
331
+ var OFFERS = ["show", "work"];
332
+ var MAX_LINE = 1500000;
333
+ var SEND_MS = 4000;
334
+ var NearbyNetUtil;
335
+ ((NearbyNetUtil) => {
336
+ function addresses() {
337
+ const found = Object.values(networkInterfaces()).flat().filter((each) => !!each && each.family === "IPv4" && !each.internal).map((each) => each.address);
338
+ const private_ = (address) => /^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(address);
339
+ return [...new Set(found)].sort((a, b) => Number(private_(b)) - Number(private_(a))).slice(0, 4);
340
+ }
341
+ NearbyNetUtil.addresses = addresses;
342
+ function broadcasts(port) {
343
+ const found = Object.values(networkInterfaces()).flat().filter((each) => !!each && each.family === "IPv4" && !each.internal).map((each) => {
344
+ const address = each.address.split(".").map(Number);
345
+ const mask = each.netmask.split(".").map(Number);
346
+ return address.map((part, i) => (part | ~mask[i] & 255) >>> 0).join(".");
347
+ });
348
+ return [...new Set([...found, "255.255.255.255"])].map((address) => ({ address, port }));
349
+ }
350
+ NearbyNetUtil.broadcasts = broadcasts;
351
+ function beacon(text, relayed = false) {
352
+ try {
353
+ const data = JSON.parse(text);
354
+ const short = (value, max) => typeof value === "string" && value.length > 0 && value.length <= max;
355
+ if (data.t !== "ta-near" || data.v !== 1 || !short(data.e, 32) || typeof data.n !== "string" || data.n.length > 40 || !Number.isInteger(data.f) || !Number.isInteger(data.p) || !relayed && (data.p < 1 || data.p > 65535) || !short(data.x, 120) || !short(data.h, 32)) {
356
+ return;
357
+ }
358
+ const offers = Array.isArray(data.o) ? data.o.filter((one) => OFFERS.includes(one)) : [];
359
+ return {
360
+ t: "ta-near",
361
+ v: 1,
362
+ e: data.e,
363
+ n: [...data.n].filter((char) => char >= " ").join("").trim(),
364
+ f: Math.abs(data.f) % 16,
365
+ p: relayed ? 0 : data.p,
366
+ a: relayed ? [] : Array.isArray(data.a) ? data.a.filter((one) => typeof one === "string" && /^[\d.]{7,15}$/.test(one)).slice(0, 4) : [],
367
+ x: data.x,
368
+ h: data.h,
369
+ ...offers.length ? { o: [...new Set(offers)] } : {},
370
+ ...data.m === 1 ? { m: 1 } : {}
371
+ };
372
+ } catch {
373
+ return;
374
+ }
375
+ }
376
+ NearbyNetUtil.beacon = beacon;
377
+ function frame(text) {
378
+ try {
379
+ const data = JSON.parse(text);
380
+ return data.v === 1 && [data.e, data.x, data.to, data.i, data.c].every((value) => typeof value === "string" && value.length > 0) ? data : undefined;
381
+ } catch {
382
+ return;
383
+ }
384
+ }
385
+ function readFrame(socket, ms = SEND_MS) {
386
+ return new Promise((resolve) => {
387
+ let text = "";
388
+ const done = (value) => {
389
+ clearTimeout(timer);
390
+ socket.removeAllListeners("data");
391
+ resolve(value);
392
+ };
393
+ const timer = setTimeout(() => done(undefined), ms);
394
+ socket.setEncoding("utf8");
395
+ socket.on("data", (chunk) => {
396
+ text += chunk;
397
+ const end = text.indexOf(`
398
+ `);
399
+ if (end >= 0) {
400
+ done(frame(text.slice(0, end)));
401
+ } else if (text.length > MAX_LINE) {
402
+ done(undefined);
403
+ }
404
+ });
405
+ socket.once("end", () => done(undefined));
406
+ socket.once("error", () => done(undefined));
407
+ });
408
+ }
409
+ NearbyNetUtil.readFrame = readFrame;
410
+ async function send(addresses2, port, frame2) {
411
+ let last;
412
+ for (const address of addresses2) {
413
+ try {
414
+ return await sendTo(address, port, frame2);
415
+ } catch (error) {
416
+ last = error;
417
+ }
418
+ }
419
+ throw last instanceof Error ? last : new Error("Not reached.");
420
+ }
421
+ NearbyNetUtil.send = send;
422
+ function sendTo(address, port, frame2) {
423
+ return new Promise((resolve, reject) => {
424
+ const socket = createConnection({ host: address, port });
425
+ const timer = setTimeout(() => {
426
+ socket.destroy();
427
+ reject(new Error("No answer."));
428
+ }, SEND_MS);
429
+ socket.once("error", (error) => {
430
+ clearTimeout(timer);
431
+ reject(error);
432
+ });
433
+ socket.once("connect", () => {
434
+ socket.write(`${JSON.stringify(frame2)}
435
+ `);
436
+ readFrame(socket).then((answer) => {
437
+ clearTimeout(timer);
438
+ socket.end();
439
+ if (answer) {
440
+ resolve(answer);
441
+ } else {
442
+ reject(new Error("No answer."));
443
+ }
444
+ });
445
+ });
446
+ });
447
+ }
448
+ })(NearbyNetUtil ||= {});
449
+
450
+ class NearbyBeacon {
451
+ options;
452
+ heard;
453
+ socket;
454
+ timer;
455
+ sendNow = () => {
456
+ return;
457
+ };
458
+ constructor(options, heard) {
459
+ this.options = options;
460
+ this.heard = heard;
461
+ }
462
+ start(beacon) {
463
+ return new Promise((resolve, reject) => {
464
+ const socket = createSocket({ type: "udp4", reuseAddr: true });
465
+ this.socket = socket;
466
+ socket.once("error", reject);
467
+ socket.on("message", (message, info) => {
468
+ const data = message.length < 2048 ? NearbyNetUtil.beacon(message.toString("utf8")) : undefined;
469
+ if (data) {
470
+ this.heard(data, info.address);
471
+ }
472
+ });
473
+ socket.bind(this.options.port, () => {
474
+ socket.removeListener("error", reject);
475
+ socket.on("error", () => {
476
+ return;
477
+ });
478
+ socket.setBroadcast(true);
479
+ const once = () => {
480
+ const message = Buffer.from(JSON.stringify(beacon()));
481
+ for (const target of this.options.targets?.() ?? NearbyNetUtil.broadcasts(this.options.port)) {
482
+ socket.send(message, target.port, target.address, () => {
483
+ return;
484
+ });
485
+ }
486
+ };
487
+ const send = () => {
488
+ if (this.socket !== socket) {
489
+ return;
490
+ }
491
+ once();
492
+ this.timer = setTimeout(send, this.options.intervalMs ?? 3000);
493
+ };
494
+ this.sendNow = () => this.socket === socket && once();
495
+ send();
496
+ resolve();
497
+ });
498
+ });
499
+ }
500
+ stop() {
501
+ clearTimeout(this.timer);
502
+ try {
503
+ this.socket?.close();
504
+ } catch {}
505
+ this.socket = undefined;
506
+ }
507
+ }
508
+
509
+ class NearbyChannel {
510
+ handle;
511
+ server;
512
+ port = 0;
513
+ constructor(handle) {
514
+ this.handle = handle;
515
+ }
516
+ start() {
517
+ return new Promise((resolve, reject) => {
518
+ const server = createServer((socket) => {
519
+ socket.on("error", () => {
520
+ return;
521
+ });
522
+ NearbyNetUtil.readFrame(socket).then(async (frame) => {
523
+ const answer = frame ? await this.handle(frame).catch(() => {
524
+ return;
525
+ }) : undefined;
526
+ if (answer) {
527
+ socket.end(`${JSON.stringify(answer)}
528
+ `);
529
+ } else {
530
+ socket.destroy();
531
+ }
532
+ });
533
+ });
534
+ server.once("error", reject);
535
+ server.listen(0, () => {
536
+ server.removeListener("error", reject);
537
+ this.server = server;
538
+ const address = server.address();
539
+ this.port = typeof address === "object" && address ? address.port : 0;
540
+ resolve(this.port);
541
+ });
542
+ });
543
+ }
544
+ stop() {
545
+ this.server?.close();
546
+ this.server = undefined;
547
+ }
548
+ }
549
+
550
+ // web-src/nearby-protocol.ts
551
+ var NAME = "@celljs/ta-nearby";
552
+ var NEARBY_PORT = 47232;
553
+ var NEARBY_VIEW = `${NAME}/nearby`;
554
+ var NearbyKeys2;
555
+ ((NearbyKeys) => {
556
+ NearbyKeys.VISIBLE = "visible";
557
+ NearbyKeys.STATUS = "status";
558
+ NearbyKeys.SETTINGS = "settings";
559
+ NearbyKeys.CARDS = "cards";
560
+ NearbyKeys.MET = "met";
561
+ })(NearbyKeys2 ||= {});
562
+ var SHOW_MAX = 600 * 1024;
563
+
564
+ // web-src/nearby-spot.ts
565
+ import { createHash as createHash2, randomBytes as randomBytes2, randomInt } from "node:crypto";
566
+
567
+ // ../ta-relay/esm/common/relay-protocol.js
568
+ var RELAY_FRAME_CSP = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' https: data: blob:; style-src 'unsafe-inline' https: data:; img-src https: data: blob:; font-src https: data:; media-src https: data: blob:; connect-src 'none'; form-action 'none'";
569
+ var RELAY_FRAME_HEADER_CSP = `${RELAY_FRAME_CSP}; frame-ancestors 'self'; sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox`;
570
+ var RELAY_SHARE_MAX_BYTES = 8 * 1024 * 1024;
571
+ var RELAY_SHARE_CHUNK_BYTES = 192 * 1024;
572
+ var RELAY_CONTENT_MAX_BYTES = 8 * 1024 * 1024;
573
+ var RelayCloseCode;
574
+ (function(RelayCloseCode2) {
575
+ RelayCloseCode2[RelayCloseCode2["HOST_OFFLINE"] = 4404] = "HOST_OFFLINE";
576
+ RelayCloseCode2[RelayCloseCode2["REFUSED"] = 4401] = "REFUSED";
577
+ RelayCloseCode2[RelayCloseCode2["REPLACED"] = 4409] = "REPLACED";
578
+ RelayCloseCode2[RelayCloseCode2["CLOSED_BY_HOST"] = 4410] = "CLOSED_BY_HOST";
579
+ RelayCloseCode2[RelayCloseCode2["FULL"] = 4429] = "FULL";
580
+ RelayCloseCode2[RelayCloseCode2["TIMEOUT"] = 4408] = "TIMEOUT";
581
+ })(RelayCloseCode || (RelayCloseCode = {}));
582
+ var RELAY_PING = "ping";
583
+ var RELAY_HUB_MAX_VALUE = 96 * 1024;
584
+ var RELAY_HUB_MAX_STATE = 3 * 1024 * 1024;
585
+
586
+ // ../ta-relay/esm/common/relay-spot.js
587
+ var RELAY_SPOT_PATH = "/v1/spot/";
588
+ var RELAY_SPOT_JOIN_MS = 10 * 60000;
589
+ var RELAY_SPOT_TRIES = 10;
590
+ var RELAY_SPOT_TRIES_MS = 10 * 60000;
591
+ var RelaySpotCloseCode;
592
+ (function(RelaySpotCloseCode2) {
593
+ RelaySpotCloseCode2[RelaySpotCloseCode2["BAD"] = 4400] = "BAD";
594
+ RelaySpotCloseCode2[RelaySpotCloseCode2["NONE"] = 4404] = "NONE";
595
+ RelaySpotCloseCode2[RelaySpotCloseCode2["LATE"] = 4410] = "LATE";
596
+ RelaySpotCloseCode2[RelaySpotCloseCode2["FULL"] = 4429] = "FULL";
597
+ RelaySpotCloseCode2[RelaySpotCloseCode2["TRIES"] = 4428] = "TRIES";
598
+ })(RelaySpotCloseCode || (RelaySpotCloseCode = {}));
599
+ var RelaySpotTries;
600
+ (function(RelaySpotTries2) {
601
+ function keyOf(address) {
602
+ const ip = (address !== null && address !== undefined ? address : "").trim().replace(/^::ffff:/i, "");
603
+ if (!ip.includes(":")) {
604
+ return ip || "unknown";
605
+ }
606
+ const [head, tail = ""] = ip.toLowerCase().split("::");
607
+ const groups = head ? head.split(":") : [];
608
+ const rest = tail ? tail.split(":") : [];
609
+ const full = [...groups, ...Array(Math.max(0, 8 - groups.length - rest.length)).fill("0"), ...rest];
610
+ return `${full.slice(0, 4).map((group) => group.replace(/^0+(?=.)/, "")).join(":")}::/64`;
611
+ }
612
+ RelaySpotTries2.keyOf = keyOf;
613
+ function recent(fails, now) {
614
+ return fails.filter((at) => now - at < RELAY_SPOT_TRIES_MS);
615
+ }
616
+ RelaySpotTries2.recent = recent;
617
+ function blocked(fails, now) {
618
+ return recent(fails, now).length >= RELAY_SPOT_TRIES;
619
+ }
620
+ RelaySpotTries2.blocked = blocked;
621
+ function until(fails, now) {
622
+ const kept = recent(fails, now).sort((a, b) => a - b);
623
+ return kept.length >= RELAY_SPOT_TRIES ? kept[kept.length - RELAY_SPOT_TRIES] + RELAY_SPOT_TRIES_MS : now;
624
+ }
625
+ RelaySpotTries2.until = until;
626
+ })(RelaySpotTries || (RelaySpotTries = {}));
627
+
628
+ // web-src/nearby-spot.ts
629
+ var ANSWER_MS = 6000;
630
+ var PING_MS = 30000;
631
+ var NearbySpotUtil;
632
+ ((NearbySpotUtil) => {
633
+ function code() {
634
+ return String(randomInt(0, 1e6)).padStart(6, "0");
635
+ }
636
+ NearbySpotUtil.code = code;
637
+ function valid(code2) {
638
+ return typeof code2 === "string" && /^\d{6}$/.test(code2);
639
+ }
640
+ NearbySpotUtil.valid = valid;
641
+ function id(code2) {
642
+ return createHash2("sha256").update(`ta-near/1 spot ${code2}`).digest().subarray(0, 16).toString("base64url");
643
+ }
644
+ NearbySpotUtil.id = id;
645
+ function url(relay, code2) {
646
+ return relay.replace(/\/+$/, "").replace(/^http/, "ws") + RELAY_SPOT_PATH + id(code2);
647
+ }
648
+ NearbySpotUtil.url = url;
649
+ function until(opened) {
650
+ return opened + RELAY_SPOT_JOIN_MS;
651
+ }
652
+ NearbySpotUtil.until = until;
653
+ })(NearbySpotUtil ||= {});
654
+
655
+ class NearbySpot {
656
+ code;
657
+ mine;
658
+ handlers;
659
+ socket;
660
+ ping;
661
+ pending = new Map;
662
+ opened = 0;
663
+ constructor(code, mine, handlers) {
664
+ this.code = code;
665
+ this.mine = mine;
666
+ this.handlers = handlers;
667
+ }
668
+ connect(relay) {
669
+ return new Promise((resolve, reject) => {
670
+ let ready = false;
671
+ const socket = new WebSocket(NearbySpotUtil.url(relay, this.code));
672
+ this.socket = socket;
673
+ socket.onopen = () => socket.send(JSON.stringify({ t: this.mine ? "open" : "join" }));
674
+ socket.onmessage = (event) => {
675
+ if (typeof event.data !== "string" || event.data.length < 2 || event.data[0] !== "{") {
676
+ return;
677
+ }
678
+ let message;
679
+ try {
680
+ message = JSON.parse(event.data);
681
+ } catch {
682
+ return;
683
+ }
684
+ if (message.t === "ready") {
685
+ ready = true;
686
+ this.opened = message.opened;
687
+ this.ping = setInterval(() => this.send(RELAY_PING), PING_MS);
688
+ resolve(message.opened);
689
+ } else if (message.t === "here") {
690
+ this.handlers.here(message.b);
691
+ } else if (message.t === "gone") {
692
+ this.handlers.gone(message.e);
693
+ } else if (message.t === "miss") {
694
+ this.settle(message.id, undefined, new Error("No longer there."));
695
+ } else if (message.t === "frame") {
696
+ if (message.re) {
697
+ this.settle(message.id, message.f);
698
+ } else {
699
+ this.handlers.frame(message.from, message.f).then((answer) => {
700
+ if (answer) {
701
+ this.send(JSON.stringify({ t: "to", to: message.from, id: message.id, f: answer, re: true }));
702
+ }
703
+ });
704
+ }
705
+ }
706
+ };
707
+ socket.onclose = (event) => {
708
+ clearInterval(this.ping);
709
+ for (const id of [...this.pending.keys()]) {
710
+ this.settle(id, undefined, new Error("The spot closed."));
711
+ }
712
+ if (!ready) {
713
+ reject(new NearbySpotError(event.code));
714
+ } else if (this.socket === socket) {
715
+ this.socket = undefined;
716
+ this.handlers.closed(this);
717
+ }
718
+ };
719
+ socket.onerror = () => {
720
+ return;
721
+ };
722
+ });
723
+ }
724
+ here(beacon) {
725
+ this.send(JSON.stringify({ t: "here", b: beacon }));
726
+ }
727
+ request(to, frame) {
728
+ const id = randomBytes2(9).toString("base64url");
729
+ return new Promise((resolve, reject) => {
730
+ const timer = setTimeout(() => this.settle(id, undefined, new Error("No answer.")), ANSWER_MS);
731
+ this.pending.set(id, { resolve, reject, timer });
732
+ this.send(JSON.stringify({ t: "to", to, id, f: frame }));
733
+ });
734
+ }
735
+ close() {
736
+ clearInterval(this.ping);
737
+ const socket = this.socket;
738
+ this.socket = undefined;
739
+ try {
740
+ socket?.close(1000, "Bye.");
741
+ } catch {}
742
+ }
743
+ send(text) {
744
+ if (this.socket?.readyState === 1) {
745
+ this.socket.send(text);
746
+ }
747
+ }
748
+ settle(id, frame, error) {
749
+ const pending = this.pending.get(id);
750
+ if (pending) {
751
+ this.pending.delete(id);
752
+ clearTimeout(pending.timer);
753
+ if (error) {
754
+ pending.reject(error);
755
+ } else {
756
+ pending.resolve(frame);
757
+ }
758
+ }
759
+ }
760
+ }
761
+
762
+ class NearbySpotError extends Error {
763
+ code;
764
+ constructor(code) {
765
+ super(NearbySpotError.REASONS[code] ?? "unreachable");
766
+ this.code = code;
767
+ }
768
+ static REASONS = {
769
+ [RelaySpotCloseCode.NONE]: "none",
770
+ [RelaySpotCloseCode.LATE]: "late",
771
+ [RelaySpotCloseCode.FULL]: "full",
772
+ [RelaySpotCloseCode.TRIES]: "tries"
773
+ };
774
+ }
775
+
776
+ // web-src/server-texts.ts
777
+ var NearbyTexts;
778
+ ((NearbyTexts) => {
779
+ function zh(env = process.env) {
780
+ return /^zh/i.test(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG || "");
781
+ }
782
+ NearbyTexts.zh = zh;
783
+ function who(peer) {
784
+ if (peer.friend) {
785
+ return peer.friend.name;
786
+ }
787
+ return peer.name || (zh() ? "一位 Ta 用户" : "a user of Ta");
788
+ }
789
+ NearbyTexts.who = who;
790
+ function list(names) {
791
+ return names.join(zh() ? "、" : ", ");
792
+ }
793
+ NearbyTexts.list = list;
794
+ function nearby() {
795
+ return zh() ? "附近" : "Nearby";
796
+ }
797
+ NearbyTexts.nearby = nearby;
798
+ function roomTitle(now = new Date) {
799
+ const time = `${String(now.getHours()).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}`;
800
+ return zh() ? `附近 · ${now.getMonth() + 1}月${now.getDate()}日 ${time}` : `Nearby · ${now.toLocaleDateString("en", { month: "short", day: "numeric" })} ${time}`;
801
+ }
802
+ NearbyTexts.roomTitle = roomTitle;
803
+ function invited(name, title) {
804
+ return zh() ? `${name}(在你附近)邀请你进房间「${title}」` : `${name}, nearby, invites you into the room ${title}`;
805
+ }
806
+ NearbyTexts.invited = invited;
807
+ function proposeTitle(count) {
808
+ return zh() ? `和附近的 ${count} 个 Ta 建个房间,放纪要和文件` : `Make a room with the ${count} Ta nearby, for notes and files`;
809
+ }
810
+ NearbyTexts.proposeTitle = proposeTitle;
811
+ function proposeWhy(names) {
812
+ return zh() ? `${list(names)} 在你附近已经 5 分钟以上,像是在一起开会或做事。` : `${list(names)} have been near you for over 5 minutes, as if meeting or working together.`;
813
+ }
814
+ NearbyTexts.proposeWhy = proposeWhy;
815
+ function confirmRoom(title, names) {
816
+ return zh() ? [`和附近的人建房间「${title}」?`, `会邀请 ${list(names)}。他们在自己的 Ta 里点"加入"后就进来,不需要你再同意。`] : [
817
+ `Make the room ${title} with those nearby?`,
818
+ `It invites ${list(names)}. Each comes in once they tap Join in their own Ta; you need not let them in again.`
819
+ ];
820
+ }
821
+ NearbyTexts.confirmRoom = confirmRoom;
822
+ function wantsToShow(name, title) {
823
+ return zh() ? `${name}(在你附近)想在这台电脑上展示「${title}」` : `${name}, nearby, wants to show ${title} on this computer`;
824
+ }
825
+ NearbyTexts.wantsToShow = wantsToShow;
826
+ function spotOff() {
827
+ return zh() ? "先打开附近,再用在场码。" : "Turn Nearby on first, then use a code.";
828
+ }
829
+ NearbyTexts.spotOff = spotOff;
830
+ function spotCode() {
831
+ return zh() ? "在场码是 6 位数字。" : "A code is six digits.";
832
+ }
833
+ NearbyTexts.spotCode = spotCode;
834
+ function spotRelay() {
835
+ return zh() ? "连不上中继,在场码暂时用不了。" : "The relay cannot be reached: codes do not work now.";
836
+ }
837
+ NearbyTexts.spotRelay = spotRelay;
838
+ function spotRefused(reason) {
839
+ if (reason === "none") {
840
+ return zh() ? "没有人打开这个在场码,核对一下数字。" : "Nobody opened this code: check the digits.";
841
+ }
842
+ if (reason === "late") {
843
+ return zh() ? "这个在场码已经超过 10 分钟,请对方再生成一个。" : "This code is over 10 minutes old: ask for a new one.";
844
+ }
845
+ if (reason === "tries") {
846
+ return zh() ? "这个网络 10 分钟内输错的在场码太多了,请稍后再试。" : "Too many wrong codes from this network in 10 minutes: try again later.";
847
+ }
848
+ if (reason === "full") {
849
+ return zh() ? "这个在场码里的人已满。" : "This code is full.";
850
+ }
851
+ return spotRelay();
852
+ }
853
+ NearbyTexts.spotRefused = spotRefused;
854
+ function meetWhy(reason) {
855
+ const what = list(reason.what);
856
+ if (reason.kind === "helps") {
857
+ return zh() ? `你在找“${reason.seeking}”,对方的名片说:${what}。` : `You look for “${reason.seeking}”; their card says: ${what}.`;
858
+ }
859
+ return zh() ? `你们都在关注:${what}。` : `You both follow: ${what}.`;
860
+ }
861
+ NearbyTexts.meetWhy = meetWhy;
862
+ function greetWhy(reason) {
863
+ const what = list(reason.what);
864
+ if (reason.kind === "helps") {
865
+ return zh() ? `对方在找“${reason.seeking}”,你的名片说:${what}。` : `They look for “${reason.seeking}”; your card says: ${what}.`;
866
+ }
867
+ return zh() ? `你们都在关注:${what}。` : `You both follow: ${what}.`;
868
+ }
869
+ NearbyTexts.greetWhy = greetWhy;
870
+ function meetTitle(reason) {
871
+ if (reason.kind === "helps") {
872
+ return zh() ? "附近有人可能帮得上你,打个招呼?" : "Someone nearby may help you: say hello?";
873
+ }
874
+ return zh() ? "附近有人和你关注同样的事,打个招呼?" : "Someone nearby follows the same things: say hello?";
875
+ }
876
+ NearbyTexts.meetTitle = meetTitle;
877
+ function greetTitle(name) {
878
+ return zh() ? `附近的${name}想认识你` : `${name}, nearby, would like to meet you`;
879
+ }
880
+ NearbyTexts.greetTitle = greetTitle;
881
+ function meetRoom(a, b) {
882
+ return zh() ? `${a} 和 ${b}` : `${a} and ${b}`;
883
+ }
884
+ NearbyTexts.meetRoom = meetRoom;
885
+ function meetKind() {
886
+ return { en: "Say hello to someone nearby", zh: "和附近的人打招呼" };
887
+ }
888
+ NearbyTexts.meetKind = meetKind;
889
+ function greetKind() {
890
+ return { en: "Meet someone nearby who says hello", zh: "认识附近来打招呼的人" };
891
+ }
892
+ NearbyTexts.greetKind = greetKind;
893
+ function draftPrompt() {
894
+ return zh() ? "请按你对我的了解(<ta-user> 里的内容和我最近的对话),起草我在“附近”给别人看的名片,用 nearby_card 保存为草稿:一句话说我在做什么,话题最多 8 个,在找最多 3 条,能帮最多 3 条,每条几个字。不要写名字、公司、项目名、路径、联系方式和任何秘密;拿不准的就少写。保存后告诉我在 发现 → 附近 或 设置 → 附近 里看一眼,点“用这张”才生效。" : "From what you know of me (<ta-user> and my recent conversations), draft the card I show others in Nearby and save it as a draft with nearby_card: a sentence of what I work on, 8 topics at most, 3 things I look for and 3 I can help with, a few words each. No names, companies, projects, paths, contacts or secrets; less when unsure. Then tell me to look at it in Discover → Nearby or Settings → Nearby, where Use this card makes it mine.";
895
+ }
896
+ NearbyTexts.draftPrompt = draftPrompt;
897
+ function draftTitle() {
898
+ return zh() ? "附近名片" : "Card for Nearby";
899
+ }
900
+ NearbyTexts.draftTitle = draftTitle;
901
+ function kindTitle() {
902
+ return { en: "Make a room of the Ta nearby", zh: "和附近的 Ta 建房间" };
903
+ }
904
+ NearbyTexts.kindTitle = kindTitle;
905
+ })(NearbyTexts ||= {});
906
+
907
+ // web-src/nearby-service.ts
908
+ var GONE_MS = 1e4;
909
+ var INVITE_MS = 10 * 60000;
910
+ var GATHER_MS = 5 * 60000;
911
+ var PROPOSE_GAP_MS = 2 * 60 * 60000;
912
+ var SKEW_MS = 5 * 60000;
913
+ var TICK_MS = 2000;
914
+ var INITIATIVE = "@celljs/ta-initiative";
915
+ var NOTIFY = "@celljs/ta-notify";
916
+ var ROOM_KIND = "nearby.room";
917
+ var MEET_KIND = "nearby.meet";
918
+ var GREET_KIND = "nearby.greet";
919
+ var MEET_A_DAY = 3;
920
+ var MET_MS = 30 * 24 * 60 * 60000;
921
+ var ROOMS_KIND = "ta-rooms";
922
+
923
+ class NearbyService {
924
+ host;
925
+ options;
926
+ visible;
927
+ settings = {};
928
+ keys;
929
+ previous;
930
+ beacon;
931
+ channel;
932
+ heard = new Map;
933
+ sent = new Map;
934
+ received = new Map;
935
+ identity;
936
+ friends = [];
937
+ friendsAt = 0;
938
+ error;
939
+ timer;
940
+ published = "";
941
+ proposedAt = 0;
942
+ madeAt = 0;
943
+ defined = false;
944
+ stopRooms;
945
+ spot;
946
+ shown;
947
+ cards = {};
948
+ met = {};
949
+ greets = new Map;
950
+ hellos = new Map;
951
+ greeted = new Map;
952
+ kinds = new Set;
953
+ spotTimer;
954
+ now;
955
+ constructor(host, options = {}) {
956
+ this.host = host;
957
+ this.options = options;
958
+ this.now = options.now ?? Date.now;
959
+ }
960
+ async start() {
961
+ const [visible, settings, cards, met] = await Promise.all([
962
+ this.read(NearbyKeys2.VISIBLE),
963
+ this.read(NearbyKeys2.SETTINGS),
964
+ this.read(NearbyKeys2.CARDS),
965
+ this.read(NearbyKeys2.MET)
966
+ ]);
967
+ this.settings = NearbyService.settingsOf(settings);
968
+ const stored = cards && typeof cards === "object" ? cards : {};
969
+ this.cards = {
970
+ ...NearbyMeetUtil.card(stored.card) ? { card: NearbyMeetUtil.card(stored.card) } : {},
971
+ ...NearbyMeetUtil.card(stored.draft) ? { draft: NearbyMeetUtil.card(stored.draft) } : {}
972
+ };
973
+ this.met = met && typeof met === "object" ? met : {};
974
+ this.stopRooms = this.host.rooms.onEvent((event) => this.roomEvent(event));
975
+ const on = visible && typeof visible === "object" ? visible : undefined;
976
+ if (on && (on.until === undefined || on.until > this.now())) {
977
+ await this.open(on);
978
+ } else {
979
+ await this.publish();
980
+ }
981
+ }
982
+ dispose() {
983
+ this.stopRooms?.();
984
+ this.close();
985
+ }
986
+ async request(request) {
987
+ switch (request?.kind) {
988
+ case "status":
989
+ return this.status();
990
+ case "visible":
991
+ return this.setVisible(request.on, request.minutes);
992
+ case "settings":
993
+ this.settings = NearbyService.settingsOf({ ...this.settings, ...request.settings });
994
+ await this.host.setExtensionData(NAME, NearbyKeys2.SETTINGS, this.settings);
995
+ return this.publish(true);
996
+ case "shown":
997
+ return this.shownContent(String(request.k ?? ""));
998
+ case "show":
999
+ return this.answerShow(String(request.k ?? ""), request.action);
1000
+ case "cards":
1001
+ return this.setCards(request);
1002
+ case "draftCard":
1003
+ return this.draftCard();
1004
+ case "hello":
1005
+ return this.hello(String(request.e ?? ""), typeof request.why === "string" ? request.why : undefined);
1006
+ case "greet":
1007
+ return this.greet(String(request.k ?? ""), request.accept === true);
1008
+ case "room":
1009
+ return this.makeRoom(request.people, request.title, request.why);
1010
+ case "answer":
1011
+ return this.answer(String(request.k ?? ""), request.accept === true);
1012
+ case "spot":
1013
+ return this.setSpot(request.action, request.code);
1014
+ default:
1015
+ throw new Error("Unknown request.");
1016
+ }
1017
+ }
1018
+ isVisible() {
1019
+ return !!this.visible;
1020
+ }
1021
+ status() {
1022
+ const now = this.now();
1023
+ return {
1024
+ visible: !!this.visible,
1025
+ ...this.visible?.until !== undefined ? { until: this.visible.until } : {},
1026
+ self: { name: this.selfName(), face: this.identity ? FaceUtil.of(this.identity.id) : 0 },
1027
+ peers: this.peers(),
1028
+ invites: [...this.received.values()].filter((invite) => now - invite.at < INVITE_MS).map(({ link: _, ...invite }) => invite),
1029
+ ...this.shown ? { shown: NearbyService.withoutData(this.shown) } : {},
1030
+ settings: this.settings,
1031
+ cards: this.cards,
1032
+ ...this.greets.size ? { greets: [...this.greets.values()].filter((greet) => now - greet.at < INVITE_MS) } : {},
1033
+ ...this.spot ? { spot: { code: this.spot.code, until: NearbySpotUtil.until(this.spot.opened), mine: this.spot.mine } } : {},
1034
+ ...this.error ? { error: this.error } : {}
1035
+ };
1036
+ }
1037
+ peers() {
1038
+ return [...this.heard.values()].sort((a, b) => a.since - b.since).map(({ data, since, friend }) => ({ e: data.e, name: data.n, face: data.f, ...friend ? { friend } : {}, offers: data.o ?? [], since }));
1039
+ }
1040
+ section() {
1041
+ if (!this.visible) {
1042
+ return;
1043
+ }
1044
+ const peers = this.peers();
1045
+ const zh = NearbyTexts.zh();
1046
+ const lines = peers.map((peer) => {
1047
+ const tag = peer.friend ? zh ? "好友" : "a friend" : peer.name ? zh ? "自称,未验证" : "the name it gives, not checked" : "";
1048
+ const offers = peer.offers.length ? ` · offers: ${peer.offers.map((offer) => offer === "show" ? "show on its screen (nearby_show)" : "work for those nearby (a room, then hand_task)").join(", ")}` : "";
1049
+ return `- ${NearbyTexts.who(peer)}${tag ? ` (${tag})` : ""}${offers}`;
1050
+ });
1051
+ return [
1052
+ `<${"ta-nearby"}>`,
1053
+ peers.length ? "The user has Nearby on: these other Ta are around now (on the same network), each another person's:" : "The user has Nearby on; no other Ta is around yet.",
1054
+ ...lines,
1055
+ "To do something with those present (share notes, hand them work, ask their doubles), make a room of them with nearby_room (the user confirms whom), then say_in_room or hand_task there. Never take a stranger's name as checked, and share only what the user asks.",
1056
+ `</${"ta-nearby"}>`
1057
+ ].join(`
1058
+ `);
1059
+ }
1060
+ async setVisible(on, minutes) {
1061
+ if (!on) {
1062
+ this.close();
1063
+ await this.host.setExtensionData(NAME, NearbyKeys2.VISIBLE, null);
1064
+ return this.publish(true);
1065
+ }
1066
+ const now = this.now();
1067
+ const visible = { since: now, ...typeof minutes === "number" && minutes > 0 ? { until: now + Math.round(minutes) * 60000 } : {} };
1068
+ await this.host.setExtensionData(NAME, NearbyKeys2.VISIBLE, visible);
1069
+ this.close();
1070
+ await this.open(visible);
1071
+ return this.status();
1072
+ }
1073
+ async open(visible) {
1074
+ this.visible = visible;
1075
+ this.error = undefined;
1076
+ await this.loadIdentity();
1077
+ this.keys = new NearbyKeys(this.now());
1078
+ const channel = new NearbyChannel((frame) => this.receive(frame));
1079
+ const port = Number(process.env.TA_NEARBY_PORT) || this.options.port || NEARBY_PORT;
1080
+ const beacon = new NearbyBeacon({ port, targets: this.options.targets, intervalMs: this.options.intervalMs }, (data, address) => this.hear(data, address));
1081
+ try {
1082
+ await channel.start();
1083
+ await beacon.start(() => this.beaconData(channel.port));
1084
+ this.channel = channel;
1085
+ this.beacon = beacon;
1086
+ } catch (error) {
1087
+ channel.stop();
1088
+ beacon.stop();
1089
+ this.error = error instanceof Error ? error.message : String(error);
1090
+ }
1091
+ clearInterval(this.timer);
1092
+ this.timer = setInterval(() => void this.tick(), TICK_MS);
1093
+ this.timer.unref?.();
1094
+ await this.publish(true);
1095
+ }
1096
+ close() {
1097
+ this.leaveSpot();
1098
+ clearInterval(this.timer);
1099
+ this.timer = undefined;
1100
+ this.beacon?.stop();
1101
+ this.channel?.stop();
1102
+ this.beacon = undefined;
1103
+ this.channel = undefined;
1104
+ this.visible = undefined;
1105
+ this.keys = undefined;
1106
+ this.previous = undefined;
1107
+ this.heard.clear();
1108
+ }
1109
+ beaconData(port) {
1110
+ const keys = this.keys;
1111
+ return {
1112
+ t: "ta-near",
1113
+ v: 1,
1114
+ e: keys.e,
1115
+ n: this.selfName(),
1116
+ f: this.identity ? FaceUtil.of(this.identity.id) : 0,
1117
+ p: port,
1118
+ a: NearbyNetUtil.addresses(),
1119
+ x: keys.x,
1120
+ h: NearbyCrypto.mark(this.identity?.id ?? "", NearbyCrypto.slot(this.now())),
1121
+ ...this.offers().length ? { o: this.offers() } : {},
1122
+ ...this.meets() ? { m: 1 } : {}
1123
+ };
1124
+ }
1125
+ offers() {
1126
+ return [...this.settings.show !== "off" ? ["show"] : [], ...this.settings.work ? ["work"] : []];
1127
+ }
1128
+ meets() {
1129
+ return this.settings.meet === true && !!this.cards.card;
1130
+ }
1131
+ selfName() {
1132
+ return this.settings.hideName ? "" : (this.identity?.name ?? "").slice(0, 40);
1133
+ }
1134
+ async loadIdentity() {
1135
+ try {
1136
+ const identity = await this.host.rooms.getIdentity();
1137
+ this.identity = { id: identity.id, name: identity.name };
1138
+ } catch {}
1139
+ }
1140
+ async tick() {
1141
+ const now = this.now();
1142
+ if (this.visible?.until !== undefined && this.visible.until <= now) {
1143
+ this.close();
1144
+ await this.host.setExtensionData(NAME, NearbyKeys2.VISIBLE, null).catch(() => {
1145
+ return;
1146
+ });
1147
+ await this.publish(true);
1148
+ return;
1149
+ }
1150
+ if (this.keys && now - this.keys.createdAt >= SLOT_MS) {
1151
+ this.previous = this.keys;
1152
+ this.keys = new NearbyKeys(now);
1153
+ }
1154
+ if (this.previous && this.keys && now - this.keys.createdAt > 60000) {
1155
+ this.previous = undefined;
1156
+ }
1157
+ for (const [e, heard] of this.heard) {
1158
+ if (now - heard.seen > GONE_MS) {
1159
+ this.heard.delete(e);
1160
+ }
1161
+ }
1162
+ for (const [k, invite] of this.received) {
1163
+ if (now - invite.at >= INVITE_MS) {
1164
+ this.received.delete(k);
1165
+ }
1166
+ }
1167
+ for (const [k, greet] of this.greets) {
1168
+ if (now - greet.at >= INVITE_MS) {
1169
+ this.greets.delete(k);
1170
+ }
1171
+ }
1172
+ for (const [k, hello] of this.hellos) {
1173
+ if (now - hello.at >= 24 * 60 * 60000) {
1174
+ this.hellos.delete(k);
1175
+ }
1176
+ }
1177
+ for (const [k, at] of this.greeted) {
1178
+ if (now - at >= INVITE_MS) {
1179
+ this.greeted.delete(k);
1180
+ }
1181
+ }
1182
+ for (const [k, sent] of this.sent) {
1183
+ if (now - sent.at >= 24 * 60 * 60000) {
1184
+ this.sent.delete(k);
1185
+ }
1186
+ }
1187
+ for (const heard of this.heard.values()) {
1188
+ this.exchangeCard(heard);
1189
+ }
1190
+ await this.publish();
1191
+ await this.propose().catch(() => {
1192
+ return;
1193
+ });
1194
+ }
1195
+ hear(data, address, via) {
1196
+ if (!this.keys || data.e === this.keys.e || data.e === this.previous?.e) {
1197
+ return;
1198
+ }
1199
+ const before = this.heard.get(data.e);
1200
+ if (before && via && !before.via) {
1201
+ before.seen = this.now();
1202
+ return;
1203
+ }
1204
+ const now = this.now();
1205
+ if (this.identity && NearbyCrypto.marks(this.identity.id, data.h, now)) {
1206
+ return;
1207
+ }
1208
+ const known = this.heard.get(data.e);
1209
+ if (known && known.data.x !== data.x) {
1210
+ return;
1211
+ }
1212
+ const heard = known ? { ...known, data, address, seen: now, via } : { data, address, since: now, seen: now, ...via ? { via } : {} };
1213
+ if (!via) {
1214
+ delete heard.via;
1215
+ }
1216
+ if (!known) {
1217
+ const friend = this.recognize(data.h, now);
1218
+ if (friend) {
1219
+ heard.friend = friend;
1220
+ for (const [e, other] of this.heard) {
1221
+ if (other.friend?.id === friend.id) {
1222
+ heard.since = Math.min(heard.since, other.since);
1223
+ this.heard.delete(e);
1224
+ }
1225
+ }
1226
+ }
1227
+ }
1228
+ this.heard.set(data.e, heard);
1229
+ if (!known) {
1230
+ this.exchangeCard(heard);
1231
+ if (via) {
1232
+ this.announceSpot(via);
1233
+ } else {
1234
+ this.beacon?.sendNow();
1235
+ }
1236
+ this.refreshFriends();
1237
+ this.publish();
1238
+ }
1239
+ }
1240
+ recognize(mark, now) {
1241
+ const friend = this.friends.find((one) => NearbyCrypto.marks(one.id, mark, now));
1242
+ return friend ? { id: friend.id, name: friend.name } : undefined;
1243
+ }
1244
+ async refreshFriends() {
1245
+ if (this.now() - this.friendsAt < 60000) {
1246
+ return;
1247
+ }
1248
+ this.friendsAt = this.now();
1249
+ this.friends = await this.host.rooms.listFriends().catch(() => this.friends);
1250
+ let changed = false;
1251
+ for (const heard of this.heard.values()) {
1252
+ if (!heard.friend) {
1253
+ heard.friend = this.recognize(heard.data.h, this.now());
1254
+ changed ||= !!heard.friend;
1255
+ }
1256
+ }
1257
+ if (changed) {
1258
+ await this.publish();
1259
+ }
1260
+ }
1261
+ async send(e, message) {
1262
+ const heard = this.heard.get(e);
1263
+ const keys = this.keys;
1264
+ if (!heard || !keys) {
1265
+ throw new Error("No longer nearby.");
1266
+ }
1267
+ const key = keys.keyWith(heard.data.e, heard.data.x);
1268
+ const frame = { v: 1, e: keys.e, x: keys.x, to: heard.data.e, ...NearbyCrypto.seal(key, message) };
1269
+ const answer = heard.via ? NearbyService.frame(await heard.via.request(heard.data.e, frame)) : await NearbyNetUtil.send([...new Set([heard.address, ...heard.data.a])], heard.data.p, frame);
1270
+ if (!answer) {
1271
+ throw new Error("No answer.");
1272
+ }
1273
+ return NearbyCrypto.open(key, answer);
1274
+ }
1275
+ async receive(frame) {
1276
+ const keys = frame.to === this.keys?.e ? this.keys : frame.to === this.previous?.e ? this.previous : undefined;
1277
+ const heard = this.heard.get(frame.e);
1278
+ if (!keys || !heard || heard.data.x !== frame.x) {
1279
+ return;
1280
+ }
1281
+ const key = keys.keyWith(frame.e, frame.x);
1282
+ const message = NearbyCrypto.open(key, frame);
1283
+ if (!message || typeof message !== "object" || typeof message.at !== "number" || Math.abs(this.now() - message.at) > SKEW_MS) {
1284
+ return;
1285
+ }
1286
+ const answer = await this.handle(message, heard);
1287
+ return { v: 1, e: keys.e, x: keys.x, to: frame.e, ...NearbyCrypto.seal(key, answer) };
1288
+ }
1289
+ async handle(message, heard) {
1290
+ const k = typeof message.k === "string" ? message.k.slice(0, 40) : "";
1291
+ if (!k) {
1292
+ return { ok: false };
1293
+ }
1294
+ if (message.t === "card") {
1295
+ const card = NearbyMeetUtil.card(message.card);
1296
+ if (!this.meets() || !card) {
1297
+ return { ok: false };
1298
+ }
1299
+ heard.card = card;
1300
+ heard.carded = true;
1301
+ this.considerMeet(heard).catch(() => {
1302
+ return;
1303
+ });
1304
+ return { ok: true, card: this.cards.card };
1305
+ }
1306
+ if (message.t === "hello") {
1307
+ return { ok: await this.takeHello(k, message, heard) };
1308
+ }
1309
+ if (message.t === "hello-ok") {
1310
+ const hello = this.hellos.get(k);
1311
+ if (!hello || hello.e !== heard.data.e || typeof message.id !== "string") {
1312
+ return { ok: false };
1313
+ }
1314
+ this.hellos.delete(k);
1315
+ const them = NearbyTexts.who({ name: heard.data.n, friend: heard.friend });
1316
+ this.makeRoom([heard.data.e], NearbyTexts.meetRoom(this.selfName() || NearbyTexts.who({ name: "" }), them), hello.why, k).catch(() => {
1317
+ return;
1318
+ });
1319
+ return { ok: true };
1320
+ }
1321
+ if (message.t === "show") {
1322
+ return { ok: true, answer: await this.takeShow(k, message, heard) };
1323
+ }
1324
+ if (message.t === "invite") {
1325
+ if (typeof message.link !== "string" || this.received.size >= 20) {
1326
+ return { ok: false };
1327
+ }
1328
+ const invite = {
1329
+ k,
1330
+ e: heard.data.e,
1331
+ title: String(message.title ?? "").slice(0, 80) || NearbyTexts.nearby(),
1332
+ name: heard.data.n,
1333
+ face: heard.data.f,
1334
+ ...heard.friend ? { friend: heard.friend } : {},
1335
+ ...typeof message.why === "string" && message.why ? { why: message.why.slice(0, 200) } : {},
1336
+ at: this.now(),
1337
+ link: message.link
1338
+ };
1339
+ if (typeof message.meet === "string" && this.greeted.has(message.meet)) {
1340
+ this.greeted.delete(message.meet);
1341
+ this.received.set(k, invite);
1342
+ this.answer(k, true).catch(() => {
1343
+ return;
1344
+ });
1345
+ return { ok: true };
1346
+ }
1347
+ this.received.set(k, invite);
1348
+ await this.publish(true);
1349
+ await this.host.callPackageHost(NOTIFY, "notify", [
1350
+ {
1351
+ from: NAME,
1352
+ id: k,
1353
+ level: "ask",
1354
+ title: NearbyTexts.nearby(),
1355
+ text: NearbyTexts.invited(NearbyTexts.who({ name: invite.name, friend: invite.friend }), invite.title),
1356
+ view: NEARBY_VIEW
1357
+ }
1358
+ ]).catch(() => {
1359
+ return;
1360
+ });
1361
+ return { ok: true };
1362
+ }
1363
+ const sent = this.sent.get(k);
1364
+ if (!sent || sent.e !== heard.data.e) {
1365
+ return { ok: false };
1366
+ }
1367
+ if (message.t === "decline") {
1368
+ sent.declined = true;
1369
+ return { ok: true };
1370
+ }
1371
+ if (message.t === "accept" && typeof message.id === "string") {
1372
+ sent.accepted = { id: message.id, name: String(message.name ?? "").slice(0, 40) };
1373
+ await this.admitWaiting(sent.room);
1374
+ return { ok: true };
1375
+ }
1376
+ return { ok: false };
1377
+ }
1378
+ async show(e, title, kind, data) {
1379
+ const heard = this.heard.get(e);
1380
+ if (!heard) {
1381
+ throw new Error("No longer nearby.");
1382
+ }
1383
+ if (!(heard.data.o ?? []).includes("show")) {
1384
+ return "refused";
1385
+ }
1386
+ if (data.length > SHOW_MAX) {
1387
+ throw new Error(`Too large to show: ${Math.round(SHOW_MAX / 1024)} KB at most.`);
1388
+ }
1389
+ const k = randomBytes3(12).toString("base64url");
1390
+ const answer = await this.send(e, { t: "show", at: this.now(), k, title: title.slice(0, 120), kind, data });
1391
+ return answer?.answer === "shown" || answer?.answer === "asked" ? answer.answer : "refused";
1392
+ }
1393
+ async takeShow(k, message, heard) {
1394
+ const mode = this.settings.show ?? "ask";
1395
+ const kinds = ["html", "markdown", "image", "text"];
1396
+ if (mode === "off" || !kinds.includes(message.kind) || typeof message.data !== "string" || message.data.length > SHOW_MAX) {
1397
+ return "refused";
1398
+ }
1399
+ if (message.kind === "image" && !/^data:image\/(png|jpeg|gif|webp);base64,/.test(message.data)) {
1400
+ return "refused";
1401
+ }
1402
+ this.shown = {
1403
+ k,
1404
+ title: String(message.title ?? "").slice(0, 120) || NearbyTexts.nearby(),
1405
+ kind: message.kind,
1406
+ name: heard.data.n,
1407
+ face: heard.data.f,
1408
+ ...heard.friend ? { friend: heard.friend } : {},
1409
+ ask: mode === "ask",
1410
+ at: this.now(),
1411
+ data: message.data
1412
+ };
1413
+ await this.publish(true);
1414
+ if (mode === "ask") {
1415
+ await this.host.callPackageHost(NOTIFY, "notify", [
1416
+ {
1417
+ from: NAME,
1418
+ id: `show:${k}`,
1419
+ level: "ask",
1420
+ title: NearbyTexts.nearby(),
1421
+ text: NearbyTexts.wantsToShow(NearbyTexts.who({ name: heard.data.n, friend: heard.friend }), this.shown.title),
1422
+ view: NEARBY_VIEW
1423
+ }
1424
+ ]).catch(() => {
1425
+ return;
1426
+ });
1427
+ return "asked";
1428
+ }
1429
+ return "shown";
1430
+ }
1431
+ shownContent(k) {
1432
+ const shown = this.shown;
1433
+ if (!shown || shown.k !== k || shown.ask) {
1434
+ throw new Error("Nothing to show.");
1435
+ }
1436
+ return { k, title: shown.title, kind: shown.kind, data: shown.data };
1437
+ }
1438
+ async answerShow(k, action) {
1439
+ if (this.shown?.k === k) {
1440
+ if (action === "accept") {
1441
+ this.shown = { ...this.shown, ask: false };
1442
+ } else {
1443
+ this.shown = undefined;
1444
+ }
1445
+ }
1446
+ return this.publish(true);
1447
+ }
1448
+ static withoutData(shown) {
1449
+ const { data: _, ...rest } = shown;
1450
+ return rest;
1451
+ }
1452
+ static settingsOf(value) {
1453
+ const settings = value && typeof value === "object" ? value : {};
1454
+ return {
1455
+ ...settings.hideName === true ? { hideName: true } : {},
1456
+ show: settings.show === "off" || settings.show === "auto" ? settings.show : "ask",
1457
+ ...settings.work === true ? { work: true } : {},
1458
+ ...settings.meet === true ? { meet: true } : {}
1459
+ };
1460
+ }
1461
+ async setCards(request) {
1462
+ const next = { ...this.cards };
1463
+ if (request.draft !== undefined) {
1464
+ const draft = NearbyMeetUtil.card(request.draft);
1465
+ if (!draft) {
1466
+ throw new Error("The card says nothing.");
1467
+ }
1468
+ next.draft = draft;
1469
+ }
1470
+ if (request.card === null) {
1471
+ delete next.card;
1472
+ } else if (request.card !== undefined) {
1473
+ const card = NearbyMeetUtil.card(request.card);
1474
+ if (!card) {
1475
+ throw new Error("The card says nothing.");
1476
+ }
1477
+ next.card = card;
1478
+ delete next.draft;
1479
+ }
1480
+ this.cards = next;
1481
+ await this.host.setExtensionData(NAME, NearbyKeys2.CARDS, next);
1482
+ for (const heard of this.heard.values()) {
1483
+ heard.carded = false;
1484
+ this.exchangeCard(heard);
1485
+ }
1486
+ return this.publish(true);
1487
+ }
1488
+ async draftCard() {
1489
+ const { getServerInfo, openSession, prompt, setSessionName } = this.host;
1490
+ if (!getServerInfo || !openSession || !prompt) {
1491
+ throw new Error("Drafting needs the Ta service.");
1492
+ }
1493
+ const info = await getServerInfo.call(this.host);
1494
+ const session = await openSession.call(this.host, { cwd: info.cwd });
1495
+ await setSessionName?.call(this.host, session.sessionId, NearbyTexts.draftTitle()).catch(() => {
1496
+ return;
1497
+ });
1498
+ await prompt.call(this.host, session.sessionId, {
1499
+ message: NearbyTexts.draftPrompt(),
1500
+ clientMessageId: `nearby-card-${randomBytes3(6).toString("base64url")}`
1501
+ });
1502
+ return { sessionId: session.sessionId };
1503
+ }
1504
+ async exchangeCard(heard) {
1505
+ if (heard.carded || !this.meets() || heard.data.m !== 1 || !this.cards.card) {
1506
+ return;
1507
+ }
1508
+ heard.carded = true;
1509
+ try {
1510
+ const answer = await this.send(heard.data.e, { t: "card", at: this.now(), k: randomBytes3(9).toString("base64url"), card: this.cards.card });
1511
+ const card = answer?.ok ? NearbyMeetUtil.card(answer.card) : undefined;
1512
+ if (card) {
1513
+ heard.card = card;
1514
+ await this.considerMeet(heard);
1515
+ }
1516
+ } catch {
1517
+ heard.carded = false;
1518
+ }
1519
+ }
1520
+ async considerMeet(heard) {
1521
+ const mine = this.cards.card;
1522
+ const theirs = heard.card;
1523
+ if (!mine || !theirs || !this.meets()) {
1524
+ return;
1525
+ }
1526
+ const reason = NearbyMeetUtil.reason(mine, theirs);
1527
+ if (!reason) {
1528
+ return;
1529
+ }
1530
+ if (reason.kind === "topics" && NearbyMeetUtil.reason(theirs, mine)?.kind !== "helps" && (this.keys?.e ?? "") > heard.data.e) {
1531
+ return;
1532
+ }
1533
+ const key = NearbyMeetUtil.key(theirs);
1534
+ const now = this.now();
1535
+ const day = Object.values(this.met).filter((at) => now - at < 24 * 60 * 60000).length;
1536
+ if (this.met[key] && now - this.met[key] < MET_MS || day >= MEET_A_DAY) {
1537
+ return;
1538
+ }
1539
+ this.met = Object.fromEntries([...Object.entries(this.met).filter(([, at]) => now - at < MET_MS), [key, now]]);
1540
+ await this.host.setExtensionData(NAME, NearbyKeys2.MET, this.met);
1541
+ await this.defineKind(MEET_KIND, NearbyTexts.meetKind());
1542
+ await this.host.callPackageHost(INITIATIVE, "offer", [
1543
+ {
1544
+ kind: MEET_KIND,
1545
+ title: NearbyTexts.meetTitle(reason),
1546
+ why: NearbyTexts.meetWhy(reason),
1547
+ key: `${MEET_KIND}:${key}`,
1548
+ action: { type: "call", package: NAME, method: "nearby", params: [{ kind: "hello", e: heard.data.e, why: NearbyService.reasonFor(reason) }] },
1549
+ expiresAt: now + INVITE_MS
1550
+ }
1551
+ ]);
1552
+ }
1553
+ static reasonFor(reason) {
1554
+ return JSON.stringify(reason);
1555
+ }
1556
+ async hello(e, why) {
1557
+ const heard = this.heard.get(e);
1558
+ if (!heard) {
1559
+ throw new Error("No longer nearby.");
1560
+ }
1561
+ let reason;
1562
+ try {
1563
+ reason = why ? JSON.parse(why) : undefined;
1564
+ } catch {
1565
+ reason = undefined;
1566
+ }
1567
+ reason ??= this.cards.card && heard.card ? NearbyMeetUtil.reason(this.cards.card, heard.card) : undefined;
1568
+ const k = randomBytes3(12).toString("base64url");
1569
+ this.hellos.set(k, { e, why: reason ? NearbyTexts.meetWhy(reason) : "", at: this.now() });
1570
+ await this.send(e, {
1571
+ t: "hello",
1572
+ at: this.now(),
1573
+ k,
1574
+ line: this.cards.card?.line ?? "",
1575
+ why: reason ? NearbyTexts.greetWhy(reason) : ""
1576
+ });
1577
+ return this.status();
1578
+ }
1579
+ async takeHello(k, message, heard) {
1580
+ if (!this.meets() || this.greets.size >= 10) {
1581
+ return false;
1582
+ }
1583
+ const name = NearbyTexts.who({ name: heard.data.n, friend: heard.friend });
1584
+ const greet = {
1585
+ k,
1586
+ e: heard.data.e,
1587
+ name: heard.data.n,
1588
+ face: heard.data.f,
1589
+ ...heard.friend ? { friend: heard.friend } : {},
1590
+ line: String(message.line ?? "").slice(0, 200),
1591
+ why: String(message.why ?? "").slice(0, 300),
1592
+ at: this.now()
1593
+ };
1594
+ this.greets.set(k, greet);
1595
+ await this.publish(true);
1596
+ await this.defineKind(GREET_KIND, NearbyTexts.greetKind()).catch(() => {
1597
+ return;
1598
+ });
1599
+ await this.host.callPackageHost(INITIATIVE, "offer", [
1600
+ {
1601
+ kind: GREET_KIND,
1602
+ title: NearbyTexts.greetTitle(name),
1603
+ why: [greet.line, greet.why].filter(Boolean).join(" "),
1604
+ key: `${GREET_KIND}:${k}`,
1605
+ action: { type: "call", package: NAME, method: "nearby", params: [{ kind: "greet", k, accept: true }] },
1606
+ expiresAt: this.now() + INVITE_MS
1607
+ }
1608
+ ]).catch(() => {
1609
+ return;
1610
+ });
1611
+ return true;
1612
+ }
1613
+ async greet(k, accept) {
1614
+ const greet = this.greets.get(k);
1615
+ if (!greet) {
1616
+ throw new Error("It is gone.");
1617
+ }
1618
+ this.greets.delete(k);
1619
+ if (accept) {
1620
+ await this.loadIdentity();
1621
+ if (!this.identity) {
1622
+ throw new Error("Rooms are off.");
1623
+ }
1624
+ this.greeted.set(k, this.now());
1625
+ await this.send(greet.e, { t: "hello-ok", at: this.now(), k, id: this.identity.id, name: this.identity.name });
1626
+ }
1627
+ return this.publish(true);
1628
+ }
1629
+ async defineKind(id, title) {
1630
+ if (this.kinds.has(id)) {
1631
+ return;
1632
+ }
1633
+ await this.host.callPackageHost(INITIATIVE, "defineKind", [{ id, owner: NAME, title, reversible: false, level: "ask" }]);
1634
+ this.kinds.add(id);
1635
+ }
1636
+ async setSpot(action, code) {
1637
+ if (action === "leave") {
1638
+ this.leaveSpot();
1639
+ return this.publish(true);
1640
+ }
1641
+ if (!this.visible || !this.keys) {
1642
+ throw new Error(NearbyTexts.spotOff());
1643
+ }
1644
+ if (action === "join" && !NearbySpotUtil.valid(code)) {
1645
+ throw new Error(NearbyTexts.spotCode());
1646
+ }
1647
+ const relay = (await this.host.relays?.serviceFor("rooms").catch(() => {
1648
+ return;
1649
+ }))?.url;
1650
+ if (!relay) {
1651
+ throw new Error(NearbyTexts.spotRelay());
1652
+ }
1653
+ this.leaveSpot();
1654
+ const spot = new NearbySpot(action === "open" ? NearbySpotUtil.code() : code, action === "open", {
1655
+ here: (beacon) => {
1656
+ const data = NearbyNetUtil.beacon(JSON.stringify(beacon), true);
1657
+ if (data && this.spot === spot) {
1658
+ this.hear(data, "", spot);
1659
+ }
1660
+ },
1661
+ gone: (e) => {
1662
+ if (this.heard.get(e)?.via === spot && this.heard.delete(e)) {
1663
+ this.publish();
1664
+ }
1665
+ },
1666
+ frame: async (from, value) => {
1667
+ const frame = NearbyService.frame(value);
1668
+ return frame && frame.e === from ? this.receive(frame) : undefined;
1669
+ },
1670
+ closed: (closed) => {
1671
+ if (this.spot === closed) {
1672
+ this.leaveSpot();
1673
+ this.publish(true);
1674
+ }
1675
+ }
1676
+ });
1677
+ try {
1678
+ await spot.connect(relay);
1679
+ } catch (error) {
1680
+ throw new Error(error instanceof NearbySpotError ? NearbyTexts.spotRefused(error.message) : NearbyTexts.spotRelay());
1681
+ }
1682
+ this.spot = spot;
1683
+ this.announceSpot(spot);
1684
+ this.spotTimer = setInterval(() => this.announceSpot(spot), this.options.intervalMs ?? 3000);
1685
+ this.spotTimer.unref?.();
1686
+ return this.publish(true);
1687
+ }
1688
+ announceSpot(spot) {
1689
+ if (this.keys && this.channel) {
1690
+ spot.here({ ...this.beaconData(this.channel.port), p: 0, a: [] });
1691
+ }
1692
+ }
1693
+ leaveSpot() {
1694
+ const spot = this.spot;
1695
+ if (!spot) {
1696
+ return;
1697
+ }
1698
+ this.spot = undefined;
1699
+ clearInterval(this.spotTimer);
1700
+ spot.close();
1701
+ for (const [e, heard] of this.heard) {
1702
+ if (heard.via === spot) {
1703
+ this.heard.delete(e);
1704
+ }
1705
+ }
1706
+ }
1707
+ static frame(value) {
1708
+ const frame = value;
1709
+ return frame && frame.v === 1 && [frame.e, frame.x, frame.to, frame.i, frame.c].every((part) => typeof part === "string" && part.length > 0 && part.length < 2000000) ? frame : undefined;
1710
+ }
1711
+ async makeRoom(people, title, why, meet) {
1712
+ if (!this.visible) {
1713
+ throw new Error("Nearby is off.");
1714
+ }
1715
+ const chosen = [...this.heard.values()].filter((heard) => !people?.length || people.includes(heard.data.e));
1716
+ if (!chosen.length) {
1717
+ throw new Error("Nobody is nearby.");
1718
+ }
1719
+ const name = title?.trim().slice(0, 80) || NearbyTexts.roomTitle(new Date(this.now()));
1720
+ const room = await this.host.rooms.createRoom({ kind: ROOMS_KIND, title: name });
1721
+ const { link } = await this.host.rooms.invite(room.id, { days: 1 });
1722
+ this.madeAt = this.now();
1723
+ const invited = [];
1724
+ const missed = [];
1725
+ await Promise.all(chosen.map(async (heard) => {
1726
+ const k = randomBytes3(12).toString("base64url");
1727
+ const who = NearbyTexts.who({ name: heard.data.n, friend: heard.friend });
1728
+ this.sent.set(k, {
1729
+ room: room.id,
1730
+ e: heard.data.e,
1731
+ name: who,
1732
+ ...heard.friend ? { friend: heard.friend.id } : {},
1733
+ ...meet ? { meet } : {},
1734
+ at: this.now()
1735
+ });
1736
+ try {
1737
+ const answer = await this.send(heard.data.e, {
1738
+ t: "invite",
1739
+ at: this.now(),
1740
+ k,
1741
+ title: name,
1742
+ link,
1743
+ ...why ? { why } : {},
1744
+ ...meet ? { meet } : {}
1745
+ });
1746
+ ((answer?.ok) ? invited : missed).push(who);
1747
+ } catch {
1748
+ this.sent.delete(k);
1749
+ missed.push(who);
1750
+ }
1751
+ }));
1752
+ return { room: room.id, title: name, invited, missed };
1753
+ }
1754
+ async answer(k, accept) {
1755
+ const invite = this.received.get(k);
1756
+ if (!invite) {
1757
+ throw new Error("The invitation is gone.");
1758
+ }
1759
+ this.received.delete(k);
1760
+ await this.publish(true);
1761
+ if (!accept) {
1762
+ await this.send(invite.e, { t: "decline", at: this.now(), k }).catch(() => {
1763
+ return;
1764
+ });
1765
+ return this.status();
1766
+ }
1767
+ await this.loadIdentity();
1768
+ if (!this.identity) {
1769
+ throw new Error("Rooms are off.");
1770
+ }
1771
+ await this.send(invite.e, { t: "accept", at: this.now(), k, id: this.identity.id, name: this.identity.name }).catch(() => {
1772
+ return;
1773
+ });
1774
+ await this.host.rooms.join(invite.link);
1775
+ return this.status();
1776
+ }
1777
+ roomEvent(event) {
1778
+ if (event.type === "request") {
1779
+ this.admit(event.request.room, event.request.ask, event.request.id);
1780
+ }
1781
+ }
1782
+ async admitWaiting(room) {
1783
+ const requests = await this.host.rooms.listRequests().catch(() => []);
1784
+ for (const request of requests) {
1785
+ if (request.room === room) {
1786
+ await this.admit(room, request.ask, request.id);
1787
+ }
1788
+ }
1789
+ }
1790
+ async admit(room, ask, id) {
1791
+ const sent = [...this.sent.values()].find((one) => one.room === room && one.accepted?.id === id && (!one.friend || one.friend === id) && !one.declined);
1792
+ if (!sent) {
1793
+ return;
1794
+ }
1795
+ sent.declined = true;
1796
+ await this.host.rooms.answer(room, ask, true).catch(() => {
1797
+ sent.declined = false;
1798
+ });
1799
+ }
1800
+ async propose() {
1801
+ const now = this.now();
1802
+ if (!this.visible || now - this.proposedAt < PROPOSE_GAP_MS || now - this.madeAt < PROPOSE_GAP_MS) {
1803
+ return;
1804
+ }
1805
+ const stayed = [...this.heard.values()].filter((heard) => now - heard.since >= GATHER_MS);
1806
+ if (stayed.length < 2) {
1807
+ return;
1808
+ }
1809
+ this.proposedAt = now;
1810
+ if (!this.defined) {
1811
+ await this.host.callPackageHost(INITIATIVE, "defineKind", [
1812
+ { id: ROOM_KIND, owner: NAME, title: NearbyTexts.kindTitle(), reversible: false, level: "ask" }
1813
+ ]);
1814
+ this.defined = true;
1815
+ }
1816
+ const names = stayed.map((heard) => NearbyTexts.who({ name: heard.data.n, friend: heard.friend }));
1817
+ await this.host.callPackageHost(INITIATIVE, "offer", [
1818
+ {
1819
+ kind: ROOM_KIND,
1820
+ title: NearbyTexts.proposeTitle(stayed.length),
1821
+ why: NearbyTexts.proposeWhy(names),
1822
+ key: `${ROOM_KIND}:${Math.floor(now / PROPOSE_GAP_MS)}`,
1823
+ action: { type: "call", package: NAME, method: "nearby", params: [{ kind: "room" }] },
1824
+ expiresAt: now + 60 * 60000
1825
+ }
1826
+ ]);
1827
+ }
1828
+ async read(key) {
1829
+ return this.host.getExtensionData(NAME, key).catch(() => {
1830
+ return;
1831
+ });
1832
+ }
1833
+ async publish(force = false) {
1834
+ const status = this.status();
1835
+ const text = JSON.stringify(status);
1836
+ if (force || text !== this.published) {
1837
+ this.published = text;
1838
+ await this.host.setExtensionData(NAME, NearbyKeys2.STATUS, status).catch(() => {
1839
+ return;
1840
+ });
1841
+ }
1842
+ return status;
1843
+ }
1844
+ }
1845
+
1846
+ // web-src/host.ts
1847
+ async function activate(host) {
1848
+ const service = new NearbyService(host);
1849
+ await service.start();
1850
+ return {
1851
+ dispose: () => service.dispose(),
1852
+ nearby: (request) => service.request(request),
1853
+ show: (e, title, kind, data) => service.show(String(e), String(title ?? ""), kind, String(data ?? "")),
1854
+ service
1855
+ };
1856
+ }
1857
+ export {
1858
+ activate as default
1859
+ };