@peers-app/peers-ui 0.0.14

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 (404) hide show
  1. package/.github/README.md +52 -0
  2. package/.github/workflows/publish.yml +45 -0
  3. package/babel.config.js +7 -0
  4. package/dist/app.d.ts +9 -0
  5. package/dist/app.js +54 -0
  6. package/dist/command-palette/command-palette-ui.d.ts +2 -0
  7. package/dist/command-palette/command-palette-ui.js +192 -0
  8. package/dist/command-palette/command-palette.d.ts +23 -0
  9. package/dist/command-palette/command-palette.js +371 -0
  10. package/dist/components/checkbox.d.ts +7 -0
  11. package/dist/components/checkbox.js +20 -0
  12. package/dist/components/group-switcher.d.ts +6 -0
  13. package/dist/components/group-switcher.js +301 -0
  14. package/dist/components/input-date.d.ts +7 -0
  15. package/dist/components/input-date.js +19 -0
  16. package/dist/components/input-datetime.d.ts +7 -0
  17. package/dist/components/input-datetime.js +35 -0
  18. package/dist/components/input-number.d.ts +9 -0
  19. package/dist/components/input-number.js +87 -0
  20. package/dist/components/input.d.ts +7 -0
  21. package/dist/components/input.js +20 -0
  22. package/dist/components/io-schema-values.d.ts +15 -0
  23. package/dist/components/io-schema-values.js +105 -0
  24. package/dist/components/io-schema.d.ts +13 -0
  25. package/dist/components/io-schema.js +163 -0
  26. package/dist/components/lazy-list.d.ts +13 -0
  27. package/dist/components/lazy-list.js +91 -0
  28. package/dist/components/lazy-sortable-list.d.ts +29 -0
  29. package/dist/components/lazy-sortable-list.js +12 -0
  30. package/dist/components/left-bar.d.ts +3 -0
  31. package/dist/components/left-bar.js +130 -0
  32. package/dist/components/list-screen.d.ts +16 -0
  33. package/dist/components/list-screen.js +100 -0
  34. package/dist/components/loading-indicator.d.ts +2 -0
  35. package/dist/components/loading-indicator.js +12 -0
  36. package/dist/components/main-content-container.d.ts +2 -0
  37. package/dist/components/main-content-container.js +90 -0
  38. package/dist/components/markdown-editor/autolink-plugin.d.ts +2 -0
  39. package/dist/components/markdown-editor/autolink-plugin.js +29 -0
  40. package/dist/components/markdown-editor/editor-inline.d.ts +3 -0
  41. package/dist/components/markdown-editor/editor-inline.js +13 -0
  42. package/dist/components/markdown-editor/editor.d.ts +18 -0
  43. package/dist/components/markdown-editor/editor.js +143 -0
  44. package/dist/components/markdown-editor/markdown-plugin.d.ts +9 -0
  45. package/dist/components/markdown-editor/markdown-plugin.js +194 -0
  46. package/dist/components/markdown-editor/mention-node.d.ts +21 -0
  47. package/dist/components/markdown-editor/mention-node.js +160 -0
  48. package/dist/components/markdown-editor/mentions-plugin.d.ts +7 -0
  49. package/dist/components/markdown-editor/mentions-plugin.js +268 -0
  50. package/dist/components/markdown-editor/theme.d.ts +46 -0
  51. package/dist/components/markdown-editor/theme.js +48 -0
  52. package/dist/components/markdown-editor/toolbar.d.ts +10 -0
  53. package/dist/components/markdown-editor/toolbar.js +112 -0
  54. package/dist/components/markdown-with-mentions.d.ts +4 -0
  55. package/dist/components/markdown-with-mentions.js +140 -0
  56. package/dist/components/message-logs/message-logs.d.ts +6 -0
  57. package/dist/components/message-logs/message-logs.js +307 -0
  58. package/dist/components/messages/avatar.d.ts +10 -0
  59. package/dist/components/messages/avatar.js +65 -0
  60. package/dist/components/messages/channel-message-list.d.ts +14 -0
  61. package/dist/components/messages/channel-message-list.js +158 -0
  62. package/dist/components/messages/channel-view.d.ts +6 -0
  63. package/dist/components/messages/channel-view.js +82 -0
  64. package/dist/components/messages/message-compose.d.ts +11 -0
  65. package/dist/components/messages/message-compose.js +152 -0
  66. package/dist/components/messages/message-display.d.ts +10 -0
  67. package/dist/components/messages/message-display.js +152 -0
  68. package/dist/components/messages/thread-message-list.d.ts +11 -0
  69. package/dist/components/messages/thread-message-list.js +122 -0
  70. package/dist/components/messages/thread-view.d.ts +6 -0
  71. package/dist/components/messages/thread-view.js +174 -0
  72. package/dist/components/off-canvas.d.ts +13 -0
  73. package/dist/components/off-canvas.js +89 -0
  74. package/dist/components/router.d.ts +6 -0
  75. package/dist/components/router.js +240 -0
  76. package/dist/components/save-button.d.ts +13 -0
  77. package/dist/components/save-button.js +75 -0
  78. package/dist/components/sortable-list.d.ts +36 -0
  79. package/dist/components/sortable-list.js +77 -0
  80. package/dist/components/tabs.d.ts +11 -0
  81. package/dist/components/tabs.js +69 -0
  82. package/dist/components/text-list-editor.tsx/text-list-editor.d.ts +6 -0
  83. package/dist/components/text-list-editor.tsx/text-list-editor.js +13 -0
  84. package/dist/components/tooltip.d.ts +11 -0
  85. package/dist/components/tooltip.js +20 -0
  86. package/dist/components/top-bar.d.ts +2 -0
  87. package/dist/components/top-bar.js +51 -0
  88. package/dist/components/typeahead/mentions-plugin.d.ts +7 -0
  89. package/dist/components/typeahead/mentions-plugin.js +203 -0
  90. package/dist/components/typeahead/typeahead-editor.d.ts +15 -0
  91. package/dist/components/typeahead/typeahead-editor.js +134 -0
  92. package/dist/components/typeahead/typeahead.d.ts +12 -0
  93. package/dist/components/typeahead/typeahead.js +94 -0
  94. package/dist/components/typeahead.d.ts +22 -0
  95. package/dist/components/typeahead.js +270 -0
  96. package/dist/globals.d.ts +29 -0
  97. package/dist/globals.js +148 -0
  98. package/dist/hooks.d.ts +34 -0
  99. package/dist/hooks.js +137 -0
  100. package/dist/index.d.ts +4 -0
  101. package/dist/index.js +20 -0
  102. package/dist/layout-vars.d.ts +6 -0
  103. package/dist/layout-vars.js +10 -0
  104. package/dist/mention-configs.d.ts +18 -0
  105. package/dist/mention-configs.js +149 -0
  106. package/dist/screens/assistants/assistant-config.d.ts +5 -0
  107. package/dist/screens/assistants/assistant-config.js +52 -0
  108. package/dist/screens/assistants/assistant-details.d.ts +4 -0
  109. package/dist/screens/assistants/assistant-details.js +85 -0
  110. package/dist/screens/assistants/assistant-info.d.ts +6 -0
  111. package/dist/screens/assistants/assistant-info.js +28 -0
  112. package/dist/screens/assistants/assistant-list.d.ts +2 -0
  113. package/dist/screens/assistants/assistant-list.js +114 -0
  114. package/dist/screens/assistants/assistant-tools.d.ts +5 -0
  115. package/dist/screens/assistants/assistant-tools.js +38 -0
  116. package/dist/screens/contacts/contact-details.d.ts +6 -0
  117. package/dist/screens/contacts/contact-details.js +100 -0
  118. package/dist/screens/contacts/contact-list.d.ts +2 -0
  119. package/dist/screens/contacts/contact-list.js +213 -0
  120. package/dist/screens/contacts/index.d.ts +4 -0
  121. package/dist/screens/contacts/index.js +21 -0
  122. package/dist/screens/events/cron.d.ts +3 -0
  123. package/dist/screens/events/cron.js +77 -0
  124. package/dist/screens/events/event-details.d.ts +6 -0
  125. package/dist/screens/events/event-details.js +112 -0
  126. package/dist/screens/events/event-handlers.d.ts +7 -0
  127. package/dist/screens/events/event-handlers.js +84 -0
  128. package/dist/screens/events/event-info.d.ts +5 -0
  129. package/dist/screens/events/event-info.js +19 -0
  130. package/dist/screens/events/event-list.d.ts +2 -0
  131. package/dist/screens/events/event-list.js +107 -0
  132. package/dist/screens/events/event-schedule.d.ts +5 -0
  133. package/dist/screens/events/event-schedule.js +124 -0
  134. package/dist/screens/groups/group-details.d.ts +6 -0
  135. package/dist/screens/groups/group-details.js +218 -0
  136. package/dist/screens/groups/group-list.d.ts +2 -0
  137. package/dist/screens/groups/group-list.js +275 -0
  138. package/dist/screens/groups/group-members.d.ts +8 -0
  139. package/dist/screens/groups/group-members.js +315 -0
  140. package/dist/screens/groups/index.d.ts +6 -0
  141. package/dist/screens/groups/index.js +23 -0
  142. package/dist/screens/knowledge/knowledge-frame-details.bk.d.ts +6 -0
  143. package/dist/screens/knowledge/knowledge-frame-details.bk.js +84 -0
  144. package/dist/screens/knowledge/knowledge-frame-details.d.ts +8 -0
  145. package/dist/screens/knowledge/knowledge-frame-details.js +143 -0
  146. package/dist/screens/knowledge/knowledge-frame-list.d.ts +2 -0
  147. package/dist/screens/knowledge/knowledge-frame-list.js +45 -0
  148. package/dist/screens/knowledge/knowledge-value-details.d.ts +6 -0
  149. package/dist/screens/knowledge/knowledge-value-details.js +150 -0
  150. package/dist/screens/knowledge/knowledge-value-list-item.d.ts +5 -0
  151. package/dist/screens/knowledge/knowledge-value-list-item.js +39 -0
  152. package/dist/screens/knowledge/knowledge-value-list.d.ts +3 -0
  153. package/dist/screens/knowledge/knowledge-value-list.js +123 -0
  154. package/dist/screens/packages/package-details.d.ts +6 -0
  155. package/dist/screens/packages/package-details.js +82 -0
  156. package/dist/screens/packages/package-info.d.ts +5 -0
  157. package/dist/screens/packages/package-info.js +42 -0
  158. package/dist/screens/packages/package-list.d.ts +2 -0
  159. package/dist/screens/packages/package-list.js +182 -0
  160. package/dist/screens/packages/package-new-local.d.ts +2 -0
  161. package/dist/screens/packages/package-new-local.js +82 -0
  162. package/dist/screens/peer-types/peer-type-details.d.ts +10 -0
  163. package/dist/screens/peer-types/peer-type-details.js +126 -0
  164. package/dist/screens/peer-types/peer-type-list.d.ts +2 -0
  165. package/dist/screens/peer-types/peer-type-list.js +57 -0
  166. package/dist/screens/predicates/predicate-details.d.ts +6 -0
  167. package/dist/screens/predicates/predicate-details.js +103 -0
  168. package/dist/screens/predicates/predicate-list.d.ts +2 -0
  169. package/dist/screens/predicates/predicate-list.js +46 -0
  170. package/dist/screens/profile.d.ts +2 -0
  171. package/dist/screens/profile.js +66 -0
  172. package/dist/screens/search/global-search.d.ts +2 -0
  173. package/dist/screens/search/global-search.js +186 -0
  174. package/dist/screens/settings/color-mode-dropdown.d.ts +6 -0
  175. package/dist/screens/settings/color-mode-dropdown.js +63 -0
  176. package/dist/screens/settings/settings-page.d.ts +2 -0
  177. package/dist/screens/settings/settings-page.js +49 -0
  178. package/dist/screens/setup-user.d.ts +2 -0
  179. package/dist/screens/setup-user.js +270 -0
  180. package/dist/screens/tools/tool-code.d.ts +5 -0
  181. package/dist/screens/tools/tool-code.js +32 -0
  182. package/dist/screens/tools/tool-details.d.ts +6 -0
  183. package/dist/screens/tools/tool-details.js +68 -0
  184. package/dist/screens/tools/tool-info.d.ts +5 -0
  185. package/dist/screens/tools/tool-info.js +74 -0
  186. package/dist/screens/tools/tool-list.d.ts +2 -0
  187. package/dist/screens/tools/tool-list.js +123 -0
  188. package/dist/screens/tools/tool-schema.d.ts +5 -0
  189. package/dist/screens/tools/tool-schema.js +30 -0
  190. package/dist/screens/tools/tool-test-details.d.ts +4 -0
  191. package/dist/screens/tools/tool-test-details.js +54 -0
  192. package/dist/screens/tools/tool-test-list.d.ts +4 -0
  193. package/dist/screens/tools/tool-test-list.js +82 -0
  194. package/dist/screens/variables/variable-details.d.ts +6 -0
  195. package/dist/screens/variables/variable-details.js +140 -0
  196. package/dist/screens/variables/variable-list.d.ts +2 -0
  197. package/dist/screens/variables/variable-list.js +58 -0
  198. package/dist/screens/workflows/workflow-details.d.ts +6 -0
  199. package/dist/screens/workflows/workflow-details.js +122 -0
  200. package/dist/screens/workflows/workflow-info.d.ts +5 -0
  201. package/dist/screens/workflows/workflow-info.js +18 -0
  202. package/dist/screens/workflows/workflow-instructions.d.ts +5 -0
  203. package/dist/screens/workflows/workflow-instructions.js +118 -0
  204. package/dist/screens/workflows/workflow-list.d.ts +2 -0
  205. package/dist/screens/workflows/workflow-list.js +109 -0
  206. package/dist/screens/workflows/workflow-subscriptions.d.ts +6 -0
  207. package/dist/screens/workflows/workflow-subscriptions.js +81 -0
  208. package/dist/setupTests.d.ts +1 -0
  209. package/dist/setupTests.js +31 -0
  210. package/dist/system-apps/assistants.app.d.ts +2 -0
  211. package/dist/system-apps/assistants.app.js +8 -0
  212. package/dist/system-apps/contacts.app.d.ts +2 -0
  213. package/dist/system-apps/contacts.app.js +9 -0
  214. package/dist/system-apps/events.app.d.ts +2 -0
  215. package/dist/system-apps/events.app.js +8 -0
  216. package/dist/system-apps/groups.app.d.ts +2 -0
  217. package/dist/system-apps/groups.app.js +9 -0
  218. package/dist/system-apps/index.d.ts +19 -0
  219. package/dist/system-apps/index.js +90 -0
  220. package/dist/system-apps/knowledge-frames.app.d.ts +2 -0
  221. package/dist/system-apps/knowledge-frames.app.js +9 -0
  222. package/dist/system-apps/knowledge-values.app.d.ts +2 -0
  223. package/dist/system-apps/knowledge-values.app.js +9 -0
  224. package/dist/system-apps/packages.app.d.ts +2 -0
  225. package/dist/system-apps/packages.app.js +8 -0
  226. package/dist/system-apps/predicates.app.d.ts +2 -0
  227. package/dist/system-apps/predicates.app.js +8 -0
  228. package/dist/system-apps/profile.app.d.ts +2 -0
  229. package/dist/system-apps/profile.app.js +8 -0
  230. package/dist/system-apps/search.app.d.ts +2 -0
  231. package/dist/system-apps/search.app.js +9 -0
  232. package/dist/system-apps/settings.app.d.ts +2 -0
  233. package/dist/system-apps/settings.app.js +8 -0
  234. package/dist/system-apps/threads.app.d.ts +2 -0
  235. package/dist/system-apps/threads.app.js +8 -0
  236. package/dist/system-apps/tools.app.d.ts +2 -0
  237. package/dist/system-apps/tools.app.js +8 -0
  238. package/dist/system-apps/types.app.d.ts +2 -0
  239. package/dist/system-apps/types.app.js +8 -0
  240. package/dist/system-apps/variables.app.d.ts +2 -0
  241. package/dist/system-apps/variables.app.js +8 -0
  242. package/dist/system-apps/workflows.app.d.ts +2 -0
  243. package/dist/system-apps/workflows.app.js +8 -0
  244. package/dist/tabs-layout/tabs-layout.d.ts +5 -0
  245. package/dist/tabs-layout/tabs-layout.js +374 -0
  246. package/dist/tabs-layout/tabs-state.d.ts +26 -0
  247. package/dist/tabs-layout/tabs-state.js +239 -0
  248. package/dist/three-bar-layout/left-bar-content.d.ts +7 -0
  249. package/dist/three-bar-layout/left-bar-content.js +151 -0
  250. package/dist/three-bar-layout/right-bar-content.d.ts +2 -0
  251. package/dist/three-bar-layout/right-bar-content.js +64 -0
  252. package/dist/three-bar-layout/three-bar-layout.d.ts +5 -0
  253. package/dist/three-bar-layout/three-bar-layout.js +218 -0
  254. package/dist/ui-defaults/index.d.ts +2 -0
  255. package/dist/ui-defaults/index.js +4 -0
  256. package/dist/ui-defaults/list-screen.d.ts +6 -0
  257. package/dist/ui-defaults/list-screen.js +74 -0
  258. package/dist/ui-defaults/notes-editor.d.ts +7 -0
  259. package/dist/ui-defaults/notes-editor.js +41 -0
  260. package/dist/ui-router/routes-loader.d.ts +25 -0
  261. package/dist/ui-router/routes-loader.js +97 -0
  262. package/dist/ui-router/ui-loader.d.ts +18 -0
  263. package/dist/ui-router/ui-loader.js +481 -0
  264. package/dist/utils.d.ts +9 -0
  265. package/dist/utils.js +250 -0
  266. package/docs/conversation-tab.md +201 -0
  267. package/docs/getting-started.md +284 -0
  268. package/docs/knowledge.md +187 -0
  269. package/docs/tabs-ui.md +696 -0
  270. package/docs/user-contacts-ui.md +384 -0
  271. package/jest.config.js +25 -0
  272. package/package.json +109 -0
  273. package/src/app.tsx +59 -0
  274. package/src/command-palette/command-palette-ui.tsx +264 -0
  275. package/src/command-palette/command-palette.ts +364 -0
  276. package/src/components/checkbox.tsx +22 -0
  277. package/src/components/group-switcher.tsx +469 -0
  278. package/src/components/input-date.tsx +28 -0
  279. package/src/components/input-datetime.tsx +41 -0
  280. package/src/components/input-number.tsx +67 -0
  281. package/src/components/input.tsx +22 -0
  282. package/src/components/io-schema-values.tsx +122 -0
  283. package/src/components/io-schema.tsx +234 -0
  284. package/src/components/lazy-list.tsx +98 -0
  285. package/src/components/lazy-sortable-list.tsx +51 -0
  286. package/src/components/left-bar.tsx +264 -0
  287. package/src/components/list-screen.tsx +105 -0
  288. package/src/components/loading-indicator.tsx +9 -0
  289. package/src/components/main-content-container.tsx +76 -0
  290. package/src/components/markdown-editor/autolink-plugin.tsx +36 -0
  291. package/src/components/markdown-editor/editor-inline.tsx +10 -0
  292. package/src/components/markdown-editor/editor.tsx +152 -0
  293. package/src/components/markdown-editor/markdown-plugin.tsx +224 -0
  294. package/src/components/markdown-editor/mention-node.ts +199 -0
  295. package/src/components/markdown-editor/mentions-plugin.tsx +356 -0
  296. package/src/components/markdown-editor/theme.ts +47 -0
  297. package/src/components/markdown-editor/toolbar.tsx +263 -0
  298. package/src/components/markdown-with-mentions.tsx +183 -0
  299. package/src/components/message-logs/message-logs.tsx +406 -0
  300. package/src/components/messages/avatar.tsx +95 -0
  301. package/src/components/messages/channel-message-list.tsx +177 -0
  302. package/src/components/messages/channel-view.tsx +74 -0
  303. package/src/components/messages/message-compose.tsx +162 -0
  304. package/src/components/messages/message-display.tsx +217 -0
  305. package/src/components/messages/thread-message-list.tsx +126 -0
  306. package/src/components/messages/thread-view.tsx +214 -0
  307. package/src/components/off-canvas.tsx +83 -0
  308. package/src/components/router.tsx +224 -0
  309. package/src/components/save-button.tsx +109 -0
  310. package/src/components/sortable-list.tsx +102 -0
  311. package/src/components/tabs.tsx +70 -0
  312. package/src/components/text-list-editor.tsx/text-list-editor.tsx +13 -0
  313. package/src/components/tooltip.tsx +50 -0
  314. package/src/components/top-bar.tsx +119 -0
  315. package/src/components/typeahead/mentions-plugin.tsx +265 -0
  316. package/src/components/typeahead/typeahead-editor.tsx +140 -0
  317. package/src/components/typeahead/typeahead.tsx +77 -0
  318. package/src/components/typeahead.tsx +359 -0
  319. package/src/globals.tsx +162 -0
  320. package/src/hooks.ts +144 -0
  321. package/src/index.tsx +8 -0
  322. package/src/layout-vars.ts +8 -0
  323. package/src/mention-configs.ts +166 -0
  324. package/src/screens/assistants/assistant-config.tsx +80 -0
  325. package/src/screens/assistants/assistant-details.tsx +77 -0
  326. package/src/screens/assistants/assistant-info.tsx +45 -0
  327. package/src/screens/assistants/assistant-list.tsx +115 -0
  328. package/src/screens/assistants/assistant-tools.tsx +61 -0
  329. package/src/screens/contacts/contact-details.tsx +175 -0
  330. package/src/screens/contacts/contact-list.tsx +251 -0
  331. package/src/screens/contacts/index.ts +6 -0
  332. package/src/screens/events/cron.ts +74 -0
  333. package/src/screens/events/event-details.tsx +117 -0
  334. package/src/screens/events/event-handlers.tsx +61 -0
  335. package/src/screens/events/event-info.tsx +29 -0
  336. package/src/screens/events/event-list.tsx +104 -0
  337. package/src/screens/events/event-schedule.tsx +130 -0
  338. package/src/screens/groups/group-details.tsx +306 -0
  339. package/src/screens/groups/group-list.tsx +366 -0
  340. package/src/screens/groups/group-members.tsx +455 -0
  341. package/src/screens/groups/index.ts +9 -0
  342. package/src/screens/knowledge/knowledge-frame-details.bk.tsx +160 -0
  343. package/src/screens/knowledge/knowledge-frame-details.tsx +176 -0
  344. package/src/screens/knowledge/knowledge-frame-list.tsx +49 -0
  345. package/src/screens/knowledge/knowledge-value-details.tsx +181 -0
  346. package/src/screens/knowledge/knowledge-value-list-item.tsx +48 -0
  347. package/src/screens/knowledge/knowledge-value-list.tsx +131 -0
  348. package/src/screens/packages/package-details.tsx +117 -0
  349. package/src/screens/packages/package-info.tsx +83 -0
  350. package/src/screens/packages/package-list.tsx +191 -0
  351. package/src/screens/packages/package-new-local.tsx +93 -0
  352. package/src/screens/peer-types/peer-type-details.tsx +162 -0
  353. package/src/screens/peer-types/peer-type-list.tsx +74 -0
  354. package/src/screens/predicates/predicate-details.tsx +125 -0
  355. package/src/screens/predicates/predicate-list.tsx +50 -0
  356. package/src/screens/profile.tsx +68 -0
  357. package/src/screens/search/global-search.tsx +274 -0
  358. package/src/screens/settings/color-mode-dropdown.tsx +57 -0
  359. package/src/screens/settings/settings-page.tsx +76 -0
  360. package/src/screens/setup-user.tsx +367 -0
  361. package/src/screens/tools/tool-code.tsx +35 -0
  362. package/src/screens/tools/tool-details.tsx +101 -0
  363. package/src/screens/tools/tool-info.tsx +60 -0
  364. package/src/screens/tools/tool-list.tsx +121 -0
  365. package/src/screens/tools/tool-schema.tsx +42 -0
  366. package/src/screens/tools/tool-test-details.tsx +100 -0
  367. package/src/screens/tools/tool-test-list.tsx +74 -0
  368. package/src/screens/variables/variable-details.tsx +183 -0
  369. package/src/screens/variables/variable-list.tsx +74 -0
  370. package/src/screens/workflows/workflow-details.tsx +130 -0
  371. package/src/screens/workflows/workflow-info.tsx +29 -0
  372. package/src/screens/workflows/workflow-instructions.tsx +127 -0
  373. package/src/screens/workflows/workflow-list.tsx +107 -0
  374. package/src/screens/workflows/workflow-subscriptions.tsx +58 -0
  375. package/src/setupTests.ts +32 -0
  376. package/src/system-apps/assistants.app.ts +7 -0
  377. package/src/system-apps/contacts.app.ts +8 -0
  378. package/src/system-apps/events.app.ts +7 -0
  379. package/src/system-apps/groups.app.ts +8 -0
  380. package/src/system-apps/index.ts +79 -0
  381. package/src/system-apps/knowledge-frames.app.ts +8 -0
  382. package/src/system-apps/knowledge-values.app.ts +8 -0
  383. package/src/system-apps/packages.app.ts +7 -0
  384. package/src/system-apps/predicates.app.ts +7 -0
  385. package/src/system-apps/profile.app.ts +7 -0
  386. package/src/system-apps/search.app.ts +8 -0
  387. package/src/system-apps/settings.app.ts +7 -0
  388. package/src/system-apps/threads.app.ts +7 -0
  389. package/src/system-apps/tools.app.ts +7 -0
  390. package/src/system-apps/types.app.ts +7 -0
  391. package/src/system-apps/variables.app.ts +7 -0
  392. package/src/system-apps/workflows.app.ts +7 -0
  393. package/src/tabs-layout/tabs-layout.tsx +672 -0
  394. package/src/tabs-layout/tabs-state.ts +269 -0
  395. package/src/three-bar-layout/left-bar-content.tsx +202 -0
  396. package/src/three-bar-layout/right-bar-content.tsx +67 -0
  397. package/src/three-bar-layout/three-bar-layout.tsx +297 -0
  398. package/src/ui-defaults/index.ts +3 -0
  399. package/src/ui-defaults/list-screen.tsx +92 -0
  400. package/src/ui-defaults/notes-editor.tsx +51 -0
  401. package/src/ui-router/routes-loader.ts +98 -0
  402. package/src/ui-router/ui-loader.tsx +497 -0
  403. package/src/utils.ts +266 -0
  404. package/tsconfig.json +24 -0
@@ -0,0 +1,183 @@
1
+ import React from 'react';
2
+ // import { FileListDisplay } from './file-list-display';
3
+ import { IMentionData, mentionRegex, rpcServerCalls } from "@peers-app/peers-sdk";
4
+ import ReactMarkdown from 'react-markdown';
5
+ import remarkGfm from 'remark-gfm';
6
+ import { mentionConfigs } from '../mention-configs';
7
+
8
+ // Custom Link Renderer
9
+ const LinkRenderer = (props: { href?: string, children?: any }) => {
10
+ const { href } = props;
11
+ return (
12
+ <a
13
+ href={href}
14
+ onClick={(e) => {
15
+ if (href?.startsWith('http')) {
16
+ e.preventDefault();
17
+ rpcServerCalls.openLinkInBrowser(href);
18
+ }
19
+ }}
20
+ >
21
+ {props.children}
22
+ </a>
23
+ );
24
+ };
25
+
26
+ const processTextWithMentions = (text: string) => {
27
+ const parts: any[] = [];
28
+ let lastIndex = 0;
29
+ let match;
30
+ let cnt = 0;
31
+
32
+ const regex = mentionRegex();
33
+ while ((match = regex.exec(text)) !== null) {
34
+ cnt++;
35
+ if (match.index > lastIndex) {
36
+ parts.push(text.slice(lastIndex, match.index));
37
+ }
38
+ text = text.slice(match.index + match[0].length);
39
+
40
+ const kind = match[2];
41
+ const name = match[3].replace(/_/g, ' ');
42
+ const id = match[4];
43
+ const data: IMentionData = {
44
+ kind,
45
+ name,
46
+ id,
47
+ };
48
+
49
+ const style = { cursor: 'pointer' } as any;
50
+ if (name.length < 20) {
51
+ style.whiteSpace = 'nowrap';
52
+ }
53
+
54
+ const mentionConfig = mentionConfigs.find(c => c.kind === kind);
55
+ const mentionClass = mentionConfig ? mentionConfig.styleClass || 'mention-default-default' : `mention-${kind}`;
56
+ const onClick = mentionConfig?.onClick;
57
+ const href = !onClick && `#${kind}s/${id}` || undefined;
58
+ const icon =
59
+ (kind === 'user' && '@') ||
60
+ mentionConfig?.iconClass && <i className={`pe-1 ${mentionConfig.iconClass}`}></i> ||
61
+ <i className={`pe-1 bi bi-question`}></i>;
62
+
63
+ parts.push(
64
+ <a
65
+ key={cnt}
66
+ className={mentionClass}
67
+ data-kind={kind}
68
+ data-id={id}
69
+ style={style}
70
+ href={href}
71
+ onClick={onClick && (() => onClick(data))}
72
+ >
73
+ {icon}
74
+ {/* {data.kind === 'task' &&
75
+ <span className='pe-1'>
76
+ <TaskCheckbox taskId={id} />
77
+ </span>
78
+ } */}
79
+ {data.name}
80
+ </a>
81
+ );
82
+ lastIndex = regex.lastIndex;
83
+ }
84
+
85
+ if (lastIndex < text.length) {
86
+ parts.push(text.slice(lastIndex));
87
+ }
88
+
89
+ return parts;
90
+ };
91
+
92
+ // const TaskCheckbox = (props: { taskId: string }) => {
93
+ // const [task, setTask] = useState<ITask | null>(null);
94
+ // const [checked, setChecked] = useState(false);
95
+
96
+ // useEffect(() => {
97
+ // Tasks().get(props.taskId).then(task => {
98
+ // if (!task) return;
99
+ // setTask(task)
100
+ // });
101
+ // const sub = Tasks().dataChanged.subscribe(evt => {
102
+ // if (evt.dataObject.taskId === props.taskId) {
103
+ // setChecked(!!evt.dataObject.completeDT);
104
+ // setTask(evt.dataObject);
105
+ // }
106
+ // });
107
+ // Tasks().get(props.taskId).then(task => {
108
+ // if (task) {
109
+ // setChecked(!!task.completeDT);
110
+ // }
111
+ // });
112
+ // return () => {
113
+ // sub.unsubscribe();
114
+ // };
115
+ // }, [props.taskId])
116
+
117
+ // return (
118
+ // <input
119
+ // type="checkbox"
120
+ // disabled={!task}
121
+ // checked={checked}
122
+ // onChange={(e) => {
123
+ // if (!task) return;
124
+ // if (checked) {
125
+ // task.completeDT = undefined;
126
+ // } else {
127
+ // task.completeDT = new Date();
128
+ // }
129
+ // Tasks().update(task);
130
+ // setChecked(!checked);
131
+ // }}
132
+ // />
133
+ // );
134
+ // };
135
+
136
+ const createElementWithMentions = (Element: any) => {
137
+ // @ts-ignore
138
+ return ({ node, ...props }) => {
139
+ return (
140
+ <Element {...props}>
141
+ {React.Children.map(props.children, child => {
142
+ if (typeof child === 'string') {
143
+ return processTextWithMentions(child);
144
+ }
145
+ return child;
146
+ })}
147
+ </Element>
148
+ );
149
+ };
150
+ };
151
+
152
+ export const MarkdownWithMentions: React.FC<{ content: string }> = ({ content }) => {
153
+ const components = {
154
+ p: createElementWithMentions('p'),
155
+ h1: createElementWithMentions('h1'),
156
+ h2: createElementWithMentions('h2'),
157
+ h3: createElementWithMentions('h3'),
158
+ h4: createElementWithMentions('h4'),
159
+ h5: createElementWithMentions('h5'),
160
+ h6: createElementWithMentions('h6'),
161
+ li: createElementWithMentions('li'),
162
+ // a: createElementWithMentions('a'),
163
+ a: LinkRenderer,
164
+ strong: createElementWithMentions('strong'),
165
+ em: createElementWithMentions('em'),
166
+ blockquote: createElementWithMentions('blockquote'),
167
+ code: createElementWithMentions('code'),
168
+ td: createElementWithMentions('td'),
169
+ th: createElementWithMentions('th'),
170
+ };
171
+
172
+ return (
173
+ <div className='markdown'>
174
+ <ReactMarkdown
175
+ remarkPlugins={[remarkGfm]}
176
+ // @ts-ignore
177
+ components={components}
178
+ >
179
+ {content}
180
+ </ReactMarkdown>
181
+ </div>
182
+ )
183
+ };
@@ -0,0 +1,406 @@
1
+ import { Assistants, formatMention, IWorkflowLog, IWorkflowRun, Observable, observable, runWorkflowToolId, Tools, WorkflowLogs, WorkflowRuns, Workflows } from "@peers-app/peers-sdk";
2
+ import { orderBy, sortBy, uniq, uniqBy } from 'lodash';
3
+ import moment from 'moment';
4
+ import React, { useEffect, useState } from 'react';
5
+ import { useObservable, useObservableState, usePromise } from "../../hooks";
6
+ import { MarkdownWithMentions } from '../markdown-with-mentions';
7
+
8
+ interface MessageLogsProps {
9
+ messageId: string;
10
+ }
11
+
12
+ export const MessageLogs = ({ messageId }: MessageLogsProps) => {
13
+ const workflowRunIds = useObservableState<string[]>([]);
14
+ const showLogs = useObservableState(false);
15
+ const [runs] = useState(() => observable([] as IWorkflowRun[]));
16
+ const [logIds] = useState(() => observable([] as string[]));
17
+
18
+ async function refreshLogCount() {
19
+ const workflowRuns = await WorkflowRuns().list({ parentMessageId: messageId });
20
+ const workflowLogs = await WorkflowLogs().list({ workflowRunId: { $in: workflowRuns.map((r) => r.workflowRunId) } });
21
+ logIds(workflowLogs.map((l) => l.workflowLogId));
22
+ }
23
+
24
+ useEffect(() => {
25
+
26
+ WorkflowRuns().list({ parentMessageId: messageId }).then(async (_runs) => {
27
+ if (!_runs.length && !runs().length) {
28
+ return;
29
+ }
30
+ runs(_runs);
31
+ refreshLogCount();
32
+ });
33
+
34
+ const subRuns = WorkflowRuns().dataChanged.subscribe(async evt => {
35
+ const workflowRun = evt.dataObject;
36
+ if (workflowRun.parentMessageId === messageId) {
37
+ let _runs = runs().filter((r) => r.workflowRunId !== workflowRun.workflowRunId);
38
+ if (evt.op !== 'delete') {
39
+ _runs.push(workflowRun);
40
+ }
41
+ runs(_runs);
42
+ refreshLogCount();
43
+ }
44
+ });
45
+
46
+ const subLogs = WorkflowLogs().dataChanged.subscribe(async evt => {
47
+ const workflowLog = evt.dataObject;
48
+ if (runs().map((r) => r.workflowRunId).includes(workflowLog.workflowRunId)) {
49
+ refreshLogCount();
50
+ }
51
+ });
52
+ return () => {
53
+ subRuns.unsubscribe();
54
+ subLogs.unsubscribe();
55
+ }
56
+ }, []);
57
+
58
+ useEffect(() => {
59
+ let disposed = false;
60
+
61
+ function upsertRunIds(ids: string[]) {
62
+ let runIds = [...workflowRunIds(), ...ids];
63
+ runIds = uniq(runIds);
64
+ runIds = runIds.sort();
65
+ workflowRunIds(runIds);
66
+ }
67
+
68
+ WorkflowRuns().list({ parentMessageId: messageId }).then(async (runs) => {
69
+ if (disposed) {
70
+ return;
71
+ }
72
+ upsertRunIds(runs.map((r) => r.workflowRunId));
73
+ });
74
+
75
+ const sub = WorkflowRuns().dataChanged.subscribe(async evt => {
76
+ const workflowRun = evt.dataObject;
77
+ if (disposed || workflowRun.parentMessageId !== messageId) {
78
+ return;
79
+ }
80
+ let runIds = workflowRunIds().filter((id) => id !== workflowRun.workflowRunId);
81
+ if (evt.op !== 'delete') {
82
+ runIds.push(workflowRun.workflowRunId);
83
+ }
84
+ runIds = uniq(runIds);
85
+ runIds = sortBy(runIds);
86
+ workflowRunIds(runIds);
87
+ });
88
+
89
+ return () => {
90
+ disposed = true;
91
+ sub.unsubscribe();
92
+ }
93
+ }, [messageId]);
94
+
95
+ if (!workflowRunIds().length) {
96
+ return false;
97
+ }
98
+
99
+ return (
100
+ <>
101
+ {/* this space prevents the logs and replies indicator from being included when selecting and copying a message text */}
102
+ &nbsp;
103
+ <ShowLogsLink logIds={logIds} showLogs={showLogs} runs={runs} />
104
+ {showLogs() && (
105
+ <div>
106
+ <AllMessageLogs logIds={logIds} runs={runs} />
107
+ </div>
108
+ )}
109
+ </>
110
+ );
111
+ }
112
+
113
+ const ShowLogsLink = (props: { showLogs: Observable<boolean>, logIds: Observable<string[]>, runs: Observable<IWorkflowRun[]> }) => {
114
+ const { showLogs, logIds, runs } = props;
115
+ useObservable(logIds);
116
+ useObservable(runs);
117
+ useObservable(showLogs);
118
+
119
+ const runsInProgress = runs().filter((r) => !r.completedAt && !r.inErrorState && (r.startedAt || !r.scheduleDT));
120
+ const runsInError = runs().filter((r) => r.inErrorState);
121
+ const runsScheduled = runs().filter((r) => !r.startedAt && !r.inErrorState && r.scheduleDT && r.scheduleDT > new Date());
122
+
123
+ return (
124
+ <div className="d-inline small">
125
+ {(runsInProgress.length > 0) && (
126
+ <div
127
+ className={`spinner-grow spinner-grow-sm text-secondary`}
128
+ role="status"
129
+ style={{
130
+ width: '0.7rem',
131
+ height: '0.7rem',
132
+ }}
133
+ >
134
+ <span className="visually-hidden">Loading...</span>
135
+ </div>
136
+ )}
137
+
138
+ {((runsInProgress.length + runsInError.length + runsScheduled.length) < 1) && (
139
+ <i className="bi bi-check-circle text-success"></i>
140
+ )}
141
+ {runsInError.length > 0 && (
142
+ <i className="bi bi-x-circle text-danger"></i>
143
+ )}
144
+ {runsScheduled.length > 0 && (
145
+ <i className="bi bi-clock text-warning" title={`Scheduled for ${moment(runsScheduled[0].scheduleDT).calendar()}`}></i>
146
+ )}
147
+
148
+ <button
149
+ className="btn btn-sm btn-link m-1 fw-lighter pt-0"
150
+ onClick={() => showLogs(!showLogs())}
151
+ tabIndex={-1}
152
+ >
153
+ <span>
154
+ {!showLogs() && (logIds().length === 1 ? '1 log' : logIds().length + ' logs')}
155
+ {showLogs() && (logIds().length === 1 ? 'hide 1 log' : `hide ${logIds().length} logs`)}
156
+ </span>
157
+ </button>
158
+
159
+ {(runsInProgress.length + runsScheduled.length) > 0 && (
160
+ <i
161
+ className="bi bi-stop-circle"
162
+ style={{ cursor: 'pointer' }}
163
+ onClick={() => {
164
+ runs().forEach((r) => {
165
+ if (!r.completedAt && !r.inErrorState) {
166
+ WorkflowRuns().haltRun(r.workflowRunId);
167
+ }
168
+ });
169
+ }}></i>
170
+ )}
171
+
172
+ </div>
173
+ );
174
+ }
175
+
176
+ const AllMessageLogs = (props: { logIds: Observable<string[]>, runs: Observable<IWorkflowRun[]> }) => {
177
+ const { logIds, runs } = props;
178
+ const runLogs = useObservableState<IWorkflowLog[]>([]);
179
+ useObservable(runLogs);
180
+
181
+ useEffect(() => {
182
+ let disposed = false;
183
+
184
+ function setLogs(logs: IWorkflowLog[]) {
185
+ logs = uniqBy(logs, l => l.workflowLogId);
186
+ logs = sortBy(logs, l => l.logDT);
187
+ runLogs(logs);
188
+ logIds(uniq([...logIds(), ...logs.map((l) => l.workflowLogId)]));
189
+ };
190
+
191
+ WorkflowLogs().list({ workflowLogId: { $in: logIds() } }).then(async (logs) => {
192
+ if (disposed) {
193
+ return;
194
+ }
195
+ setLogs([...logs, ...runLogs()]);
196
+ });
197
+
198
+ const sub = WorkflowLogs().dataChanged.subscribe(async evt => {
199
+ const workflowLog = evt.dataObject;
200
+ if (disposed || !logIds().includes(workflowLog.workflowLogId)) {
201
+ return;
202
+ }
203
+ let logs = runLogs().filter((log) => log.workflowLogId !== workflowLog.workflowLogId);
204
+ if (evt.op !== 'delete') {
205
+ logs.push(workflowLog);
206
+ }
207
+ setLogs(logs);
208
+ });
209
+
210
+ return () => {
211
+ disposed = true;
212
+ sub.unsubscribe();
213
+ }
214
+ }, []);
215
+
216
+ if (!runLogs().length) {
217
+ return false;
218
+ }
219
+
220
+ return (<RenderNextLog logs={runLogs()} runs={runs} />);
221
+ }
222
+
223
+ const RenderNextLog = (props: { logs: IWorkflowLog[], runs: Observable<IWorkflowRun[]> }) => {
224
+ let { logs, runs } = props;
225
+
226
+ if (!logs.length) {
227
+ return false;
228
+ }
229
+
230
+ logs = orderBy(logs, (l) => l.logDT);
231
+ logs = orderBy(logs, (l) => l.workflowRunId);
232
+
233
+ const nextLog = logs.shift()!;
234
+ const runsIdsInside = [nextLog.workflowRunId];
235
+ while (true) {
236
+ let subRunIds = runs().filter((r) =>
237
+ runsIdsInside.includes(r.parentWorkflowRunId ?? '')
238
+ && !runsIdsInside.includes(r.workflowRunId)
239
+ ).map((r) => r.workflowRunId);
240
+ if (!subRunIds.length) {
241
+ break;
242
+ }
243
+ runsIdsInside.push(...subRunIds);
244
+ }
245
+
246
+ const logEndDT = new Date(nextLog.logDT.getTime() + (nextLog?.toolRunTimeMs || 0));
247
+ const logsInside = logs.filter((l) => l.logDT < logEndDT && runsIdsInside.includes(l.workflowRunId));
248
+ const logsAfter = logs.filter((l) => l.logDT >= logEndDT || !runsIdsInside.includes(l.workflowRunId));
249
+
250
+ const result = nextLog.resultObject ? JSON.stringify(nextLog.resultObject, null, 2) : nextLog.result;
251
+
252
+ return (
253
+ <>
254
+ <div className='border-start rounded'>
255
+ <LogDisplay log={nextLog} />
256
+
257
+ <div className='ms-3'>
258
+ <RenderNextLog logs={logsInside} runs={runs} />
259
+ </div>
260
+
261
+ {result && (
262
+ <MarkdownWithMentions content={[
263
+ "```",
264
+ `Result: ${result}`,
265
+ "```",
266
+ ].filter(s => s).join('\n')} />
267
+ )}
268
+ </div>
269
+
270
+
271
+ {logsAfter.length > 0 && (
272
+ <RenderNextLog logs={logsAfter} runs={runs} />
273
+ )}
274
+ </>
275
+ );
276
+ }
277
+
278
+
279
+ const LogDisplay = (props: { log: IWorkflowLog }) => {
280
+ const { log } = props;
281
+ const [showMenu] = useState(() => observable(false));
282
+ const showRawJson = useObservableState(false);
283
+ const tool = usePromise(async () => {
284
+ if (log.toolId) {
285
+ const tool = await Tools().get(log.toolId);
286
+ return tool;
287
+ }
288
+ });
289
+
290
+ const subWorkflow = usePromise(async () => {
291
+ if (log.toolId === runWorkflowToolId) {
292
+ return Workflows().get(log.toolArgs?.workflowId);
293
+ }
294
+ }, undefined, [log.toolId, log.toolArgs?.workflowId]);
295
+
296
+ const assistant = usePromise(async () => {
297
+ if (log.toolArgs?.assistantId) {
298
+ return Assistants().get(log.toolArgs.assistantId);
299
+ }
300
+ }, undefined, [log.toolArgs?.assistantId]);
301
+
302
+
303
+ const rawJson = (
304
+ <pre>
305
+ {JSON.stringify(log, null, 2)}
306
+ </pre>
307
+ );
308
+
309
+ let displayElement = rawJson;
310
+
311
+ if (log.logText) {
312
+ displayElement = (
313
+ <MarkdownWithMentions content={[
314
+ "```",
315
+ log.logText,
316
+ log.instruction ? `Instruction: ${JSON.stringify(log.instruction, null, 2)}` : '',
317
+ "```",
318
+ ].filter(s => s).join('\n')} />
319
+ );
320
+ }
321
+
322
+ else if (tool && subWorkflow) {
323
+ const toolMention = formatMention({ kind: 'tool', id: tool.toolId, name: tool.name });
324
+ const workflowMention = formatMention({ kind: 'workflow', id: subWorkflow.workflowId, name: subWorkflow.name });
325
+ const args = { ...log.toolArgs };
326
+ delete args.workflowId;
327
+ displayElement = (
328
+ <MarkdownWithMentions content={[
329
+ "```",
330
+ `${workflowMention} via ${toolMention} (${log.toolRunTimeMs ?? ''}ms)`,
331
+ `Args: ${JSON.stringify(args, null, 2)}`,
332
+ "```",
333
+ ].filter(s => s).join('\n')} />
334
+ );
335
+ }
336
+
337
+ else if (tool && tool.isAssistantRunner) {
338
+ const assistantId = log.toolArgs?.assistantId;
339
+ const assistantMention = formatMention({ kind: 'assistant', id: assistantId, name: assistant?.name || assistantId || '' });
340
+ const toolMention = formatMention({ kind: 'tool', id: tool.toolId, name: tool.name ?? '' });
341
+ const args = { ...log.toolArgs };
342
+ delete args.assistantId;
343
+ displayElement = (
344
+ <MarkdownWithMentions content={[
345
+ "```",
346
+ `${assistantMention} via ${toolMention} (${log.toolRunTimeMs}ms)`,
347
+ `Args: ${JSON.stringify(args, null, 2)}`,
348
+ "```",
349
+ ].filter(s => s).join('\n')} />
350
+ );
351
+ }
352
+
353
+ else if (log.toolId) {
354
+ const toolMention = formatMention({ kind: 'tool', id: log.toolId, name: tool?.name || log.toolId });
355
+ displayElement = (
356
+ <MarkdownWithMentions content={[
357
+ "```",
358
+ log.logText && `Log Text: ${log.logText}`,
359
+ `${toolMention} (${log.toolRunTimeMs}ms)`,
360
+ `Args: ${JSON.stringify(log.toolArgs, null, 2)}`,
361
+ "```",
362
+ ].filter(s => s).join('\n')} />
363
+ );
364
+ }
365
+
366
+ const isRawView = displayElement === rawJson;
367
+
368
+ return (
369
+ <div
370
+ style={{ position: 'relative' }}
371
+ onMouseEnter={() => showMenu(true)}
372
+ onMouseLeave={() => showMenu(false)}
373
+ >
374
+
375
+ {!isRawView && (
376
+ <LogMenu showMenu={showMenu} showRawJson={showRawJson} />
377
+ )}
378
+
379
+ {showRawJson() ? rawJson : displayElement}
380
+
381
+ </div>
382
+ );
383
+ }
384
+
385
+ const LogMenu = (props: { showMenu: Observable<boolean>, showRawJson: Observable<boolean> }) => {
386
+ const { showMenu, showRawJson } = props;
387
+ useObservable(showMenu);
388
+
389
+ return (
390
+ <>
391
+ {showMenu() && (
392
+ <div className="message-hover-menu">
393
+ <button
394
+ className="btn btn-lg m-1 p-1"
395
+ onClick={() => showRawJson(!showRawJson())}
396
+ >
397
+ {showRawJson()
398
+ ? <i className="bi bi-filetype-md"></i>
399
+ : <i className="bi bi-filetype-json"></i>
400
+ }
401
+ </button>
402
+ </div>
403
+ )}
404
+ </>
405
+ )
406
+ }
@@ -0,0 +1,95 @@
1
+ import React from 'react';
2
+ import { usePromise } from '../../hooks';
3
+ import { IUser, Users, Assistants } from "@peers-app/peers-sdk";
4
+
5
+ interface IProps {
6
+ userId: string,
7
+ assistantId?: string,
8
+ setUser?: (user: IUser) => any
9
+ }
10
+
11
+ export const Avatar = (props: IProps) => {
12
+ const { userId, setUser: parentSetUser, assistantId } = props;
13
+
14
+ const user = usePromise(async () => {
15
+ const user = await Users().get(userId, { useCache: true });
16
+ if (user && parentSetUser) {
17
+ parentSetUser(user);
18
+ }
19
+ return user;
20
+ });
21
+ const assistant = usePromise(async () => {
22
+ if (assistantId) {
23
+ return Assistants().get(assistantId, { useCache: true});
24
+ }
25
+ }, undefined, [assistantId]);
26
+
27
+ let initials = "?"
28
+
29
+ let name = assistant?.name || user?.name;
30
+ if (user) {
31
+ if (!name) {
32
+ initials = "!"
33
+ } else {
34
+ const words = name.split(' ');
35
+ const first = words[0];
36
+ const last = words.length > 1 ? words[words.length-1] : words[0][1];
37
+ initials = first[0] + last[0];
38
+ }
39
+ }
40
+
41
+ // TODO if user.avatarImage then get and show that
42
+
43
+ let backgroundColor = name ? stringToHslColor(name) : stringToHslColor('', 100, 100);
44
+ if (assistant) {
45
+ // backgroundColor = stringToHslColor(name || '', 100, 100);
46
+ backgroundColor = stringToHslColor('', 0, 70);
47
+ }
48
+
49
+ return (
50
+ <div className="position-relative">
51
+ <div
52
+ className="rounded-circle d-flex justify-content-center align-items-center fs-4 border"
53
+ style={{
54
+ width: '40px',
55
+ height: '40px',
56
+ color: 'white',
57
+ backgroundColor,
58
+ }}
59
+ >
60
+ <span style={{ fontSize: '15pt' }}>
61
+ {assistant && <i className="bi bi-person-fill-gear"></i>}
62
+ {!assistant && initials.toUpperCase()}
63
+ {/* {assistant ? "ai" : initials.toUpperCase()} */}
64
+ </span>
65
+ </div>
66
+ {/* Keep this here in case we want to show the assistant icon */}
67
+ {/* {assistantId && (
68
+ <i
69
+ className="bi bi-gear-fill position-absolute"
70
+ style={{
71
+ bottom: '0',
72
+ right: '0',
73
+ fontSize: '12px',
74
+ backgroundColor: 'white',
75
+ borderRadius: '50%',
76
+ padding: '2px',
77
+ }}
78
+ title={`${user?.name}'s assistant`}
79
+ ></i>
80
+ )} */}
81
+ </div>
82
+ );
83
+ }
84
+
85
+ export function stringToHslColor(str: string = '', saturation: number = 50, lightness: number = 40) {
86
+ saturation = saturation % 100;
87
+ lightness = lightness % 100;
88
+ var hash = 0;
89
+ for (var i = 0; i < str.length; i++) {
90
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
91
+ }
92
+
93
+ var h = hash % 360;
94
+ return 'hsl('+h+', '+saturation+'%, '+lightness+'%)';
95
+ }