@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.
- package/.github/README.md +52 -0
- package/.github/workflows/publish.yml +45 -0
- package/babel.config.js +7 -0
- package/dist/app.d.ts +9 -0
- package/dist/app.js +54 -0
- package/dist/command-palette/command-palette-ui.d.ts +2 -0
- package/dist/command-palette/command-palette-ui.js +192 -0
- package/dist/command-palette/command-palette.d.ts +23 -0
- package/dist/command-palette/command-palette.js +371 -0
- package/dist/components/checkbox.d.ts +7 -0
- package/dist/components/checkbox.js +20 -0
- package/dist/components/group-switcher.d.ts +6 -0
- package/dist/components/group-switcher.js +301 -0
- package/dist/components/input-date.d.ts +7 -0
- package/dist/components/input-date.js +19 -0
- package/dist/components/input-datetime.d.ts +7 -0
- package/dist/components/input-datetime.js +35 -0
- package/dist/components/input-number.d.ts +9 -0
- package/dist/components/input-number.js +87 -0
- package/dist/components/input.d.ts +7 -0
- package/dist/components/input.js +20 -0
- package/dist/components/io-schema-values.d.ts +15 -0
- package/dist/components/io-schema-values.js +105 -0
- package/dist/components/io-schema.d.ts +13 -0
- package/dist/components/io-schema.js +163 -0
- package/dist/components/lazy-list.d.ts +13 -0
- package/dist/components/lazy-list.js +91 -0
- package/dist/components/lazy-sortable-list.d.ts +29 -0
- package/dist/components/lazy-sortable-list.js +12 -0
- package/dist/components/left-bar.d.ts +3 -0
- package/dist/components/left-bar.js +130 -0
- package/dist/components/list-screen.d.ts +16 -0
- package/dist/components/list-screen.js +100 -0
- package/dist/components/loading-indicator.d.ts +2 -0
- package/dist/components/loading-indicator.js +12 -0
- package/dist/components/main-content-container.d.ts +2 -0
- package/dist/components/main-content-container.js +90 -0
- package/dist/components/markdown-editor/autolink-plugin.d.ts +2 -0
- package/dist/components/markdown-editor/autolink-plugin.js +29 -0
- package/dist/components/markdown-editor/editor-inline.d.ts +3 -0
- package/dist/components/markdown-editor/editor-inline.js +13 -0
- package/dist/components/markdown-editor/editor.d.ts +18 -0
- package/dist/components/markdown-editor/editor.js +143 -0
- package/dist/components/markdown-editor/markdown-plugin.d.ts +9 -0
- package/dist/components/markdown-editor/markdown-plugin.js +194 -0
- package/dist/components/markdown-editor/mention-node.d.ts +21 -0
- package/dist/components/markdown-editor/mention-node.js +160 -0
- package/dist/components/markdown-editor/mentions-plugin.d.ts +7 -0
- package/dist/components/markdown-editor/mentions-plugin.js +268 -0
- package/dist/components/markdown-editor/theme.d.ts +46 -0
- package/dist/components/markdown-editor/theme.js +48 -0
- package/dist/components/markdown-editor/toolbar.d.ts +10 -0
- package/dist/components/markdown-editor/toolbar.js +112 -0
- package/dist/components/markdown-with-mentions.d.ts +4 -0
- package/dist/components/markdown-with-mentions.js +140 -0
- package/dist/components/message-logs/message-logs.d.ts +6 -0
- package/dist/components/message-logs/message-logs.js +307 -0
- package/dist/components/messages/avatar.d.ts +10 -0
- package/dist/components/messages/avatar.js +65 -0
- package/dist/components/messages/channel-message-list.d.ts +14 -0
- package/dist/components/messages/channel-message-list.js +158 -0
- package/dist/components/messages/channel-view.d.ts +6 -0
- package/dist/components/messages/channel-view.js +82 -0
- package/dist/components/messages/message-compose.d.ts +11 -0
- package/dist/components/messages/message-compose.js +152 -0
- package/dist/components/messages/message-display.d.ts +10 -0
- package/dist/components/messages/message-display.js +152 -0
- package/dist/components/messages/thread-message-list.d.ts +11 -0
- package/dist/components/messages/thread-message-list.js +122 -0
- package/dist/components/messages/thread-view.d.ts +6 -0
- package/dist/components/messages/thread-view.js +174 -0
- package/dist/components/off-canvas.d.ts +13 -0
- package/dist/components/off-canvas.js +89 -0
- package/dist/components/router.d.ts +6 -0
- package/dist/components/router.js +240 -0
- package/dist/components/save-button.d.ts +13 -0
- package/dist/components/save-button.js +75 -0
- package/dist/components/sortable-list.d.ts +36 -0
- package/dist/components/sortable-list.js +77 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +69 -0
- package/dist/components/text-list-editor.tsx/text-list-editor.d.ts +6 -0
- package/dist/components/text-list-editor.tsx/text-list-editor.js +13 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +20 -0
- package/dist/components/top-bar.d.ts +2 -0
- package/dist/components/top-bar.js +51 -0
- package/dist/components/typeahead/mentions-plugin.d.ts +7 -0
- package/dist/components/typeahead/mentions-plugin.js +203 -0
- package/dist/components/typeahead/typeahead-editor.d.ts +15 -0
- package/dist/components/typeahead/typeahead-editor.js +134 -0
- package/dist/components/typeahead/typeahead.d.ts +12 -0
- package/dist/components/typeahead/typeahead.js +94 -0
- package/dist/components/typeahead.d.ts +22 -0
- package/dist/components/typeahead.js +270 -0
- package/dist/globals.d.ts +29 -0
- package/dist/globals.js +148 -0
- package/dist/hooks.d.ts +34 -0
- package/dist/hooks.js +137 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +20 -0
- package/dist/layout-vars.d.ts +6 -0
- package/dist/layout-vars.js +10 -0
- package/dist/mention-configs.d.ts +18 -0
- package/dist/mention-configs.js +149 -0
- package/dist/screens/assistants/assistant-config.d.ts +5 -0
- package/dist/screens/assistants/assistant-config.js +52 -0
- package/dist/screens/assistants/assistant-details.d.ts +4 -0
- package/dist/screens/assistants/assistant-details.js +85 -0
- package/dist/screens/assistants/assistant-info.d.ts +6 -0
- package/dist/screens/assistants/assistant-info.js +28 -0
- package/dist/screens/assistants/assistant-list.d.ts +2 -0
- package/dist/screens/assistants/assistant-list.js +114 -0
- package/dist/screens/assistants/assistant-tools.d.ts +5 -0
- package/dist/screens/assistants/assistant-tools.js +38 -0
- package/dist/screens/contacts/contact-details.d.ts +6 -0
- package/dist/screens/contacts/contact-details.js +100 -0
- package/dist/screens/contacts/contact-list.d.ts +2 -0
- package/dist/screens/contacts/contact-list.js +213 -0
- package/dist/screens/contacts/index.d.ts +4 -0
- package/dist/screens/contacts/index.js +21 -0
- package/dist/screens/events/cron.d.ts +3 -0
- package/dist/screens/events/cron.js +77 -0
- package/dist/screens/events/event-details.d.ts +6 -0
- package/dist/screens/events/event-details.js +112 -0
- package/dist/screens/events/event-handlers.d.ts +7 -0
- package/dist/screens/events/event-handlers.js +84 -0
- package/dist/screens/events/event-info.d.ts +5 -0
- package/dist/screens/events/event-info.js +19 -0
- package/dist/screens/events/event-list.d.ts +2 -0
- package/dist/screens/events/event-list.js +107 -0
- package/dist/screens/events/event-schedule.d.ts +5 -0
- package/dist/screens/events/event-schedule.js +124 -0
- package/dist/screens/groups/group-details.d.ts +6 -0
- package/dist/screens/groups/group-details.js +218 -0
- package/dist/screens/groups/group-list.d.ts +2 -0
- package/dist/screens/groups/group-list.js +275 -0
- package/dist/screens/groups/group-members.d.ts +8 -0
- package/dist/screens/groups/group-members.js +315 -0
- package/dist/screens/groups/index.d.ts +6 -0
- package/dist/screens/groups/index.js +23 -0
- package/dist/screens/knowledge/knowledge-frame-details.bk.d.ts +6 -0
- package/dist/screens/knowledge/knowledge-frame-details.bk.js +84 -0
- package/dist/screens/knowledge/knowledge-frame-details.d.ts +8 -0
- package/dist/screens/knowledge/knowledge-frame-details.js +143 -0
- package/dist/screens/knowledge/knowledge-frame-list.d.ts +2 -0
- package/dist/screens/knowledge/knowledge-frame-list.js +45 -0
- package/dist/screens/knowledge/knowledge-value-details.d.ts +6 -0
- package/dist/screens/knowledge/knowledge-value-details.js +150 -0
- package/dist/screens/knowledge/knowledge-value-list-item.d.ts +5 -0
- package/dist/screens/knowledge/knowledge-value-list-item.js +39 -0
- package/dist/screens/knowledge/knowledge-value-list.d.ts +3 -0
- package/dist/screens/knowledge/knowledge-value-list.js +123 -0
- package/dist/screens/packages/package-details.d.ts +6 -0
- package/dist/screens/packages/package-details.js +82 -0
- package/dist/screens/packages/package-info.d.ts +5 -0
- package/dist/screens/packages/package-info.js +42 -0
- package/dist/screens/packages/package-list.d.ts +2 -0
- package/dist/screens/packages/package-list.js +182 -0
- package/dist/screens/packages/package-new-local.d.ts +2 -0
- package/dist/screens/packages/package-new-local.js +82 -0
- package/dist/screens/peer-types/peer-type-details.d.ts +10 -0
- package/dist/screens/peer-types/peer-type-details.js +126 -0
- package/dist/screens/peer-types/peer-type-list.d.ts +2 -0
- package/dist/screens/peer-types/peer-type-list.js +57 -0
- package/dist/screens/predicates/predicate-details.d.ts +6 -0
- package/dist/screens/predicates/predicate-details.js +103 -0
- package/dist/screens/predicates/predicate-list.d.ts +2 -0
- package/dist/screens/predicates/predicate-list.js +46 -0
- package/dist/screens/profile.d.ts +2 -0
- package/dist/screens/profile.js +66 -0
- package/dist/screens/search/global-search.d.ts +2 -0
- package/dist/screens/search/global-search.js +186 -0
- package/dist/screens/settings/color-mode-dropdown.d.ts +6 -0
- package/dist/screens/settings/color-mode-dropdown.js +63 -0
- package/dist/screens/settings/settings-page.d.ts +2 -0
- package/dist/screens/settings/settings-page.js +49 -0
- package/dist/screens/setup-user.d.ts +2 -0
- package/dist/screens/setup-user.js +270 -0
- package/dist/screens/tools/tool-code.d.ts +5 -0
- package/dist/screens/tools/tool-code.js +32 -0
- package/dist/screens/tools/tool-details.d.ts +6 -0
- package/dist/screens/tools/tool-details.js +68 -0
- package/dist/screens/tools/tool-info.d.ts +5 -0
- package/dist/screens/tools/tool-info.js +74 -0
- package/dist/screens/tools/tool-list.d.ts +2 -0
- package/dist/screens/tools/tool-list.js +123 -0
- package/dist/screens/tools/tool-schema.d.ts +5 -0
- package/dist/screens/tools/tool-schema.js +30 -0
- package/dist/screens/tools/tool-test-details.d.ts +4 -0
- package/dist/screens/tools/tool-test-details.js +54 -0
- package/dist/screens/tools/tool-test-list.d.ts +4 -0
- package/dist/screens/tools/tool-test-list.js +82 -0
- package/dist/screens/variables/variable-details.d.ts +6 -0
- package/dist/screens/variables/variable-details.js +140 -0
- package/dist/screens/variables/variable-list.d.ts +2 -0
- package/dist/screens/variables/variable-list.js +58 -0
- package/dist/screens/workflows/workflow-details.d.ts +6 -0
- package/dist/screens/workflows/workflow-details.js +122 -0
- package/dist/screens/workflows/workflow-info.d.ts +5 -0
- package/dist/screens/workflows/workflow-info.js +18 -0
- package/dist/screens/workflows/workflow-instructions.d.ts +5 -0
- package/dist/screens/workflows/workflow-instructions.js +118 -0
- package/dist/screens/workflows/workflow-list.d.ts +2 -0
- package/dist/screens/workflows/workflow-list.js +109 -0
- package/dist/screens/workflows/workflow-subscriptions.d.ts +6 -0
- package/dist/screens/workflows/workflow-subscriptions.js +81 -0
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +31 -0
- package/dist/system-apps/assistants.app.d.ts +2 -0
- package/dist/system-apps/assistants.app.js +8 -0
- package/dist/system-apps/contacts.app.d.ts +2 -0
- package/dist/system-apps/contacts.app.js +9 -0
- package/dist/system-apps/events.app.d.ts +2 -0
- package/dist/system-apps/events.app.js +8 -0
- package/dist/system-apps/groups.app.d.ts +2 -0
- package/dist/system-apps/groups.app.js +9 -0
- package/dist/system-apps/index.d.ts +19 -0
- package/dist/system-apps/index.js +90 -0
- package/dist/system-apps/knowledge-frames.app.d.ts +2 -0
- package/dist/system-apps/knowledge-frames.app.js +9 -0
- package/dist/system-apps/knowledge-values.app.d.ts +2 -0
- package/dist/system-apps/knowledge-values.app.js +9 -0
- package/dist/system-apps/packages.app.d.ts +2 -0
- package/dist/system-apps/packages.app.js +8 -0
- package/dist/system-apps/predicates.app.d.ts +2 -0
- package/dist/system-apps/predicates.app.js +8 -0
- package/dist/system-apps/profile.app.d.ts +2 -0
- package/dist/system-apps/profile.app.js +8 -0
- package/dist/system-apps/search.app.d.ts +2 -0
- package/dist/system-apps/search.app.js +9 -0
- package/dist/system-apps/settings.app.d.ts +2 -0
- package/dist/system-apps/settings.app.js +8 -0
- package/dist/system-apps/threads.app.d.ts +2 -0
- package/dist/system-apps/threads.app.js +8 -0
- package/dist/system-apps/tools.app.d.ts +2 -0
- package/dist/system-apps/tools.app.js +8 -0
- package/dist/system-apps/types.app.d.ts +2 -0
- package/dist/system-apps/types.app.js +8 -0
- package/dist/system-apps/variables.app.d.ts +2 -0
- package/dist/system-apps/variables.app.js +8 -0
- package/dist/system-apps/workflows.app.d.ts +2 -0
- package/dist/system-apps/workflows.app.js +8 -0
- package/dist/tabs-layout/tabs-layout.d.ts +5 -0
- package/dist/tabs-layout/tabs-layout.js +374 -0
- package/dist/tabs-layout/tabs-state.d.ts +26 -0
- package/dist/tabs-layout/tabs-state.js +239 -0
- package/dist/three-bar-layout/left-bar-content.d.ts +7 -0
- package/dist/three-bar-layout/left-bar-content.js +151 -0
- package/dist/three-bar-layout/right-bar-content.d.ts +2 -0
- package/dist/three-bar-layout/right-bar-content.js +64 -0
- package/dist/three-bar-layout/three-bar-layout.d.ts +5 -0
- package/dist/three-bar-layout/three-bar-layout.js +218 -0
- package/dist/ui-defaults/index.d.ts +2 -0
- package/dist/ui-defaults/index.js +4 -0
- package/dist/ui-defaults/list-screen.d.ts +6 -0
- package/dist/ui-defaults/list-screen.js +74 -0
- package/dist/ui-defaults/notes-editor.d.ts +7 -0
- package/dist/ui-defaults/notes-editor.js +41 -0
- package/dist/ui-router/routes-loader.d.ts +25 -0
- package/dist/ui-router/routes-loader.js +97 -0
- package/dist/ui-router/ui-loader.d.ts +18 -0
- package/dist/ui-router/ui-loader.js +481 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +250 -0
- package/docs/conversation-tab.md +201 -0
- package/docs/getting-started.md +284 -0
- package/docs/knowledge.md +187 -0
- package/docs/tabs-ui.md +696 -0
- package/docs/user-contacts-ui.md +384 -0
- package/jest.config.js +25 -0
- package/package.json +109 -0
- package/src/app.tsx +59 -0
- package/src/command-palette/command-palette-ui.tsx +264 -0
- package/src/command-palette/command-palette.ts +364 -0
- package/src/components/checkbox.tsx +22 -0
- package/src/components/group-switcher.tsx +469 -0
- package/src/components/input-date.tsx +28 -0
- package/src/components/input-datetime.tsx +41 -0
- package/src/components/input-number.tsx +67 -0
- package/src/components/input.tsx +22 -0
- package/src/components/io-schema-values.tsx +122 -0
- package/src/components/io-schema.tsx +234 -0
- package/src/components/lazy-list.tsx +98 -0
- package/src/components/lazy-sortable-list.tsx +51 -0
- package/src/components/left-bar.tsx +264 -0
- package/src/components/list-screen.tsx +105 -0
- package/src/components/loading-indicator.tsx +9 -0
- package/src/components/main-content-container.tsx +76 -0
- package/src/components/markdown-editor/autolink-plugin.tsx +36 -0
- package/src/components/markdown-editor/editor-inline.tsx +10 -0
- package/src/components/markdown-editor/editor.tsx +152 -0
- package/src/components/markdown-editor/markdown-plugin.tsx +224 -0
- package/src/components/markdown-editor/mention-node.ts +199 -0
- package/src/components/markdown-editor/mentions-plugin.tsx +356 -0
- package/src/components/markdown-editor/theme.ts +47 -0
- package/src/components/markdown-editor/toolbar.tsx +263 -0
- package/src/components/markdown-with-mentions.tsx +183 -0
- package/src/components/message-logs/message-logs.tsx +406 -0
- package/src/components/messages/avatar.tsx +95 -0
- package/src/components/messages/channel-message-list.tsx +177 -0
- package/src/components/messages/channel-view.tsx +74 -0
- package/src/components/messages/message-compose.tsx +162 -0
- package/src/components/messages/message-display.tsx +217 -0
- package/src/components/messages/thread-message-list.tsx +126 -0
- package/src/components/messages/thread-view.tsx +214 -0
- package/src/components/off-canvas.tsx +83 -0
- package/src/components/router.tsx +224 -0
- package/src/components/save-button.tsx +109 -0
- package/src/components/sortable-list.tsx +102 -0
- package/src/components/tabs.tsx +70 -0
- package/src/components/text-list-editor.tsx/text-list-editor.tsx +13 -0
- package/src/components/tooltip.tsx +50 -0
- package/src/components/top-bar.tsx +119 -0
- package/src/components/typeahead/mentions-plugin.tsx +265 -0
- package/src/components/typeahead/typeahead-editor.tsx +140 -0
- package/src/components/typeahead/typeahead.tsx +77 -0
- package/src/components/typeahead.tsx +359 -0
- package/src/globals.tsx +162 -0
- package/src/hooks.ts +144 -0
- package/src/index.tsx +8 -0
- package/src/layout-vars.ts +8 -0
- package/src/mention-configs.ts +166 -0
- package/src/screens/assistants/assistant-config.tsx +80 -0
- package/src/screens/assistants/assistant-details.tsx +77 -0
- package/src/screens/assistants/assistant-info.tsx +45 -0
- package/src/screens/assistants/assistant-list.tsx +115 -0
- package/src/screens/assistants/assistant-tools.tsx +61 -0
- package/src/screens/contacts/contact-details.tsx +175 -0
- package/src/screens/contacts/contact-list.tsx +251 -0
- package/src/screens/contacts/index.ts +6 -0
- package/src/screens/events/cron.ts +74 -0
- package/src/screens/events/event-details.tsx +117 -0
- package/src/screens/events/event-handlers.tsx +61 -0
- package/src/screens/events/event-info.tsx +29 -0
- package/src/screens/events/event-list.tsx +104 -0
- package/src/screens/events/event-schedule.tsx +130 -0
- package/src/screens/groups/group-details.tsx +306 -0
- package/src/screens/groups/group-list.tsx +366 -0
- package/src/screens/groups/group-members.tsx +455 -0
- package/src/screens/groups/index.ts +9 -0
- package/src/screens/knowledge/knowledge-frame-details.bk.tsx +160 -0
- package/src/screens/knowledge/knowledge-frame-details.tsx +176 -0
- package/src/screens/knowledge/knowledge-frame-list.tsx +49 -0
- package/src/screens/knowledge/knowledge-value-details.tsx +181 -0
- package/src/screens/knowledge/knowledge-value-list-item.tsx +48 -0
- package/src/screens/knowledge/knowledge-value-list.tsx +131 -0
- package/src/screens/packages/package-details.tsx +117 -0
- package/src/screens/packages/package-info.tsx +83 -0
- package/src/screens/packages/package-list.tsx +191 -0
- package/src/screens/packages/package-new-local.tsx +93 -0
- package/src/screens/peer-types/peer-type-details.tsx +162 -0
- package/src/screens/peer-types/peer-type-list.tsx +74 -0
- package/src/screens/predicates/predicate-details.tsx +125 -0
- package/src/screens/predicates/predicate-list.tsx +50 -0
- package/src/screens/profile.tsx +68 -0
- package/src/screens/search/global-search.tsx +274 -0
- package/src/screens/settings/color-mode-dropdown.tsx +57 -0
- package/src/screens/settings/settings-page.tsx +76 -0
- package/src/screens/setup-user.tsx +367 -0
- package/src/screens/tools/tool-code.tsx +35 -0
- package/src/screens/tools/tool-details.tsx +101 -0
- package/src/screens/tools/tool-info.tsx +60 -0
- package/src/screens/tools/tool-list.tsx +121 -0
- package/src/screens/tools/tool-schema.tsx +42 -0
- package/src/screens/tools/tool-test-details.tsx +100 -0
- package/src/screens/tools/tool-test-list.tsx +74 -0
- package/src/screens/variables/variable-details.tsx +183 -0
- package/src/screens/variables/variable-list.tsx +74 -0
- package/src/screens/workflows/workflow-details.tsx +130 -0
- package/src/screens/workflows/workflow-info.tsx +29 -0
- package/src/screens/workflows/workflow-instructions.tsx +127 -0
- package/src/screens/workflows/workflow-list.tsx +107 -0
- package/src/screens/workflows/workflow-subscriptions.tsx +58 -0
- package/src/setupTests.ts +32 -0
- package/src/system-apps/assistants.app.ts +7 -0
- package/src/system-apps/contacts.app.ts +8 -0
- package/src/system-apps/events.app.ts +7 -0
- package/src/system-apps/groups.app.ts +8 -0
- package/src/system-apps/index.ts +79 -0
- package/src/system-apps/knowledge-frames.app.ts +8 -0
- package/src/system-apps/knowledge-values.app.ts +8 -0
- package/src/system-apps/packages.app.ts +7 -0
- package/src/system-apps/predicates.app.ts +7 -0
- package/src/system-apps/profile.app.ts +7 -0
- package/src/system-apps/search.app.ts +8 -0
- package/src/system-apps/settings.app.ts +7 -0
- package/src/system-apps/threads.app.ts +7 -0
- package/src/system-apps/tools.app.ts +7 -0
- package/src/system-apps/types.app.ts +7 -0
- package/src/system-apps/variables.app.ts +7 -0
- package/src/system-apps/workflows.app.ts +7 -0
- package/src/tabs-layout/tabs-layout.tsx +672 -0
- package/src/tabs-layout/tabs-state.ts +269 -0
- package/src/three-bar-layout/left-bar-content.tsx +202 -0
- package/src/three-bar-layout/right-bar-content.tsx +67 -0
- package/src/three-bar-layout/three-bar-layout.tsx +297 -0
- package/src/ui-defaults/index.ts +3 -0
- package/src/ui-defaults/list-screen.tsx +92 -0
- package/src/ui-defaults/notes-editor.tsx +51 -0
- package/src/ui-router/routes-loader.ts +98 -0
- package/src/ui-router/ui-loader.tsx +497 -0
- package/src/utils.ts +266 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { getPrimaryAssistant, IMessage, IPublicPrivateKeys, isid, loadKeys, Messages, myUserId, newid, newKeys, openMessageWithPublicKey, rpcServerCalls, signMessageWithSecretKey, thisDeviceId, Users } from "@peers-app/peers-sdk";
|
|
2
|
+
import React, { useState } from "react";
|
|
3
|
+
import { Input } from "../components/input";
|
|
4
|
+
import { MarkdownWithMentions } from "../components/markdown-with-mentions";
|
|
5
|
+
import { Tooltip } from "../components/tooltip";
|
|
6
|
+
import { mainContentPath, me, openThread } from "../globals";
|
|
7
|
+
|
|
8
|
+
async function sendNewUserMessage(userId: string) {
|
|
9
|
+
const user = await Users().get(userId);
|
|
10
|
+
if (!user) {
|
|
11
|
+
throw new Error('user not found');
|
|
12
|
+
}
|
|
13
|
+
const primaryAssistant = await getPrimaryAssistant();
|
|
14
|
+
const message: IMessage = {
|
|
15
|
+
messageId: newid(),
|
|
16
|
+
message: [
|
|
17
|
+
`Hi, ${user.name}! Welcome to Peers! I'm your primary AI assistant.`,
|
|
18
|
+
"\n\n",
|
|
19
|
+
"If you have any questions, just ask! I'm here to help.",
|
|
20
|
+
// `\nRemind Mark to add some Getting-Started tasks that I can work through with you.`,
|
|
21
|
+
].join(' '),
|
|
22
|
+
userId: user.userId,
|
|
23
|
+
assistantId: primaryAssistant?.assistantId,
|
|
24
|
+
channelId: user.userId,
|
|
25
|
+
createdAt: new Date(),
|
|
26
|
+
}
|
|
27
|
+
await Messages().insert(message);
|
|
28
|
+
openThread(message.messageId);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const SetupUser = () => {
|
|
32
|
+
const [username, setUsername] = useState('');
|
|
33
|
+
let [userId, setUserId] = useState('');
|
|
34
|
+
const [secretKey, setSecretKey] = useState('');
|
|
35
|
+
const [existingUser, setExistingUser] = useState(false);
|
|
36
|
+
const [registerAccount, setRegisterAccount] = useState(true);
|
|
37
|
+
const [showUserKeys, setShowUserKeys] = useState(false);
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
async function onSubmit(e: React.FormEvent) {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
|
|
43
|
+
let keys: IPublicPrivateKeys;
|
|
44
|
+
if (existingUser) {
|
|
45
|
+
if (!userId || !secretKey) {
|
|
46
|
+
confirm('Please enter a userId and secret key');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (isid(userId) !== true) {
|
|
50
|
+
confirm('Invalid userId');
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
keys = loadKeys(secretKey);
|
|
55
|
+
const msg = newid();
|
|
56
|
+
const msgSigned = signMessageWithSecretKey(msg, keys.secretKey);
|
|
57
|
+
const msgOpened = openMessageWithPublicKey(msgSigned, keys.publicKey);
|
|
58
|
+
if (msg !== msgOpened) {
|
|
59
|
+
throw new Error('signed message does not match');
|
|
60
|
+
}
|
|
61
|
+
} catch (e) {
|
|
62
|
+
confirm('Invalid secret key');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
keys = newKeys();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const _userId = userId || me.userId;
|
|
70
|
+
|
|
71
|
+
let _me = await Users().get(_userId);
|
|
72
|
+
const name = username.trim() || "Unnamed_1";
|
|
73
|
+
if (!_me) {
|
|
74
|
+
_me = {
|
|
75
|
+
userId: _userId,
|
|
76
|
+
name,
|
|
77
|
+
publicKey: keys.publicKey,
|
|
78
|
+
publicBoxKey: keys.publicBoxKey,
|
|
79
|
+
};
|
|
80
|
+
await Users().insert(_me);
|
|
81
|
+
} else {
|
|
82
|
+
_me.name = name;
|
|
83
|
+
_me.publicKey = keys.publicKey;
|
|
84
|
+
_me.publicBoxKey = keys.publicBoxKey;
|
|
85
|
+
await Users().update(_me);
|
|
86
|
+
}
|
|
87
|
+
myUserId(_userId);
|
|
88
|
+
|
|
89
|
+
const result = await rpcServerCalls.setSecretKey(keys.secretKey).catch(err => {
|
|
90
|
+
confirm('Error setting user id and secret key: ' + String(err).replaceAll('\n', ' '));
|
|
91
|
+
return err;
|
|
92
|
+
});
|
|
93
|
+
if (result) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// if changing user then use new device id
|
|
97
|
+
thisDeviceId(newid());
|
|
98
|
+
if (existingUser) {
|
|
99
|
+
mainContentPath('profile');
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
mainContentPath('profile');
|
|
102
|
+
window.location.reload();
|
|
103
|
+
}, 100);
|
|
104
|
+
} else {
|
|
105
|
+
setUserId(_userId);
|
|
106
|
+
setSecretKey(keys.secretKey);
|
|
107
|
+
setShowUserKeys(true);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (showUserKeys) {
|
|
112
|
+
return <ShowUserKeys userId={userId} secretKey={secretKey} />;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<div
|
|
117
|
+
className='container-fluid'
|
|
118
|
+
>
|
|
119
|
+
<div
|
|
120
|
+
className="position-relative"
|
|
121
|
+
style={{
|
|
122
|
+
height: '100vh',
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
<div
|
|
126
|
+
className="position-absolute start-50 translate-middle bg-body-tertiary"
|
|
127
|
+
style={{
|
|
128
|
+
width: '400px',
|
|
129
|
+
padding: '20px',
|
|
130
|
+
border: '1px solid #ccc',
|
|
131
|
+
borderRadius: '5px',
|
|
132
|
+
top: '350px',
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
<h3 className='text-center'>Setup User</h3>
|
|
136
|
+
|
|
137
|
+
<form onSubmit={onSubmit}>
|
|
138
|
+
<label>Display Name</label>
|
|
139
|
+
<Tooltip
|
|
140
|
+
positions={['top', 'bottom', 'right', 'left']}
|
|
141
|
+
markdownContent="This can be whatever you want it to be. You can change it any time."
|
|
142
|
+
/>
|
|
143
|
+
<input
|
|
144
|
+
id="display-name"
|
|
145
|
+
type='text'
|
|
146
|
+
className='form-control'
|
|
147
|
+
value={username}
|
|
148
|
+
onChange={(e) => setUsername(e.target.value)}
|
|
149
|
+
/>
|
|
150
|
+
|
|
151
|
+
<div className="mt-2">
|
|
152
|
+
<label>Existing User</label>
|
|
153
|
+
<Tooltip
|
|
154
|
+
positions={['top', 'bottom', 'right', 'left']}
|
|
155
|
+
markdownContent="Check this if you have already have an account and need to enter your existing `userId` and `secretKey`."
|
|
156
|
+
/>
|
|
157
|
+
|
|
158
|
+
<input
|
|
159
|
+
type="checkbox"
|
|
160
|
+
checked={existingUser}
|
|
161
|
+
onChange={(e) => {
|
|
162
|
+
const checked = e.target.checked;
|
|
163
|
+
setExistingUser(checked);
|
|
164
|
+
if (checked) {
|
|
165
|
+
setUserId('');
|
|
166
|
+
setSecretKey('');
|
|
167
|
+
}
|
|
168
|
+
}}
|
|
169
|
+
/>
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
{existingUser && (
|
|
173
|
+
<>
|
|
174
|
+
<br />
|
|
175
|
+
<label>User Id</label>
|
|
176
|
+
<Tooltip
|
|
177
|
+
positions={['top', 'bottom', 'right', 'left']}
|
|
178
|
+
markdownContent="The user id that was generated when you first setup your account."
|
|
179
|
+
/>
|
|
180
|
+
<input
|
|
181
|
+
id="user-id"
|
|
182
|
+
type="text"
|
|
183
|
+
className='form-control'
|
|
184
|
+
value={userId}
|
|
185
|
+
onChange={(e) => setUserId(e.target.value)}
|
|
186
|
+
disabled={!existingUser}
|
|
187
|
+
/>
|
|
188
|
+
<br />
|
|
189
|
+
|
|
190
|
+
<label>Secret Key</label>
|
|
191
|
+
<Tooltip
|
|
192
|
+
positions={['top', 'bottom', 'right', 'left']}
|
|
193
|
+
markdownContent="The secret key for the public key that is currently associated with this account."
|
|
194
|
+
/>
|
|
195
|
+
<input
|
|
196
|
+
id="secret-key"
|
|
197
|
+
type='password'
|
|
198
|
+
className='form-control'
|
|
199
|
+
value={secretKey}
|
|
200
|
+
disabled={!existingUser}
|
|
201
|
+
onChange={(e) => setSecretKey(e.target.value)}
|
|
202
|
+
/>
|
|
203
|
+
</>
|
|
204
|
+
)}
|
|
205
|
+
|
|
206
|
+
<div className="mt-2">
|
|
207
|
+
<label>Sync with Peers</label>
|
|
208
|
+
<Tooltip
|
|
209
|
+
positions={['top', 'bottom', 'right', 'left']}
|
|
210
|
+
markdownContent={[
|
|
211
|
+
"### PLEASE READ",
|
|
212
|
+
'\n',
|
|
213
|
+
"Leave this checked to register your `userId` and `publicKey` with [https://peers.app](https://peers.app) server.",
|
|
214
|
+
"\n\n**No other data is sent to the server.**\n\n",
|
|
215
|
+
"This is not required to use Peers but it is required to use the built-in network services.",
|
|
216
|
+
"Additionally this will ensure that your `userId` is not used publicly by someone else.",
|
|
217
|
+
"\n\n",
|
|
218
|
+
"**This is _highly_ recommended** but if your goal is absolute privacy, uncheck this.",
|
|
219
|
+
"\n\n",
|
|
220
|
+
"If you choose to not do this now, you can still do it later from the settings screen.",
|
|
221
|
+
].join(' ')}
|
|
222
|
+
/>
|
|
223
|
+
|
|
224
|
+
<input
|
|
225
|
+
type="checkbox"
|
|
226
|
+
checked={registerAccount}
|
|
227
|
+
onChange={(e) => setRegisterAccount(e.target.checked)}
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
<button
|
|
232
|
+
className='btn btn-primary float-end'
|
|
233
|
+
onClick={e => onSubmit(e)}
|
|
234
|
+
>
|
|
235
|
+
Submit
|
|
236
|
+
</button>
|
|
237
|
+
</form>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const ShowUserKeys = (props: { userId: string, secretKey: string }) => {
|
|
245
|
+
const { userId, secretKey } = props;
|
|
246
|
+
|
|
247
|
+
const [secretKeySaved, setSecretKeySaved] = useState(false);
|
|
248
|
+
|
|
249
|
+
async function continueToApp() {
|
|
250
|
+
await sendNewUserMessage(userId);
|
|
251
|
+
window.location.reload();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const secretKeyExplainer = [
|
|
255
|
+
"**`NEVER SHARE THIS KEY WITH ANYONE!`**",
|
|
256
|
+
"\n\n",
|
|
257
|
+
"If this key is compromised another user can permanently take over your account.",
|
|
258
|
+
"\n\n",
|
|
259
|
+
"This key is used to:",
|
|
260
|
+
"\n - Sign messages so that other users can verify they were sent from you.",
|
|
261
|
+
"\n - Decrypt boxed data that was encrypted with your public box key.",
|
|
262
|
+
"\n - This allows other users to send data to you securely through public channels.",
|
|
263
|
+
"\n - Encrypt your own private data so that only you can decrypt it.",
|
|
264
|
+
"\n\n",
|
|
265
|
+
"Unlike a password, this key is never sent to the server and is entirely in your control.",
|
|
266
|
+
"This is the foundation of your account's security.",
|
|
267
|
+
"If you lose this key you will lose access to your account.",
|
|
268
|
+
"If this key is compromised your account will be too and you will be putting any groups you are a part of at risk.",
|
|
269
|
+
"\n\n",
|
|
270
|
+
"Since the secret key is never sent to the server, if you lose it you'll lose access to your account.",
|
|
271
|
+
"It is highly recommend to store these in a password manager like [1Password](https://1password.com).",
|
|
272
|
+
].join(' ');
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<div
|
|
276
|
+
className='container-fluid'
|
|
277
|
+
>
|
|
278
|
+
<div
|
|
279
|
+
className="position-relative"
|
|
280
|
+
style={{
|
|
281
|
+
height: '100vh',
|
|
282
|
+
}}
|
|
283
|
+
>
|
|
284
|
+
<div
|
|
285
|
+
className="position-absolute top-50 start-50 translate-middle bg-body-tertiary"
|
|
286
|
+
style={{
|
|
287
|
+
width: '600px',
|
|
288
|
+
padding: '20px',
|
|
289
|
+
border: '1px solid #ccc',
|
|
290
|
+
borderRadius: '5px',
|
|
291
|
+
}}
|
|
292
|
+
>
|
|
293
|
+
<h3 className='text-center'>User Created!</h3>
|
|
294
|
+
|
|
295
|
+
<small>User Id:</small>
|
|
296
|
+
<Tooltip markdownContent="This uniquely identifies you to all other users." />
|
|
297
|
+
<button
|
|
298
|
+
className='btn btn-secondary-outline'
|
|
299
|
+
onClick={() => {
|
|
300
|
+
navigator.clipboard.writeText(userId);
|
|
301
|
+
}}
|
|
302
|
+
title="Copy User Id to Clipboard"
|
|
303
|
+
>
|
|
304
|
+
<i className="bi bi-copy"></i>
|
|
305
|
+
</button>
|
|
306
|
+
<Input
|
|
307
|
+
value={me.userId}
|
|
308
|
+
className="form-control mb-3"
|
|
309
|
+
disabled
|
|
310
|
+
/>
|
|
311
|
+
|
|
312
|
+
<small>Secret Key:</small>
|
|
313
|
+
<Tooltip markdownContent={secretKeyExplainer} />
|
|
314
|
+
<button
|
|
315
|
+
className='btn btn-secondary-outline'
|
|
316
|
+
onClick={() => {
|
|
317
|
+
navigator.clipboard.writeText(props.secretKey);
|
|
318
|
+
}}
|
|
319
|
+
title="Copy Secret Key to Clipboard"
|
|
320
|
+
>
|
|
321
|
+
<i className="bi bi-copy"></i>
|
|
322
|
+
</button>
|
|
323
|
+
<pre>
|
|
324
|
+
{secretKey}
|
|
325
|
+
</pre>
|
|
326
|
+
|
|
327
|
+
<small>
|
|
328
|
+
<MarkdownWithMentions
|
|
329
|
+
content={[
|
|
330
|
+
"**`IMPORTANT:`**",
|
|
331
|
+
"**Copy your User Id and Secret Key to a secure location.**",
|
|
332
|
+
"\n\n",
|
|
333
|
+
"You won't be able to view this key again after you continue.",
|
|
334
|
+
"\n\n",
|
|
335
|
+
"It is highly recommended to store these in a password manager like [1Password](https://1password.com).",
|
|
336
|
+
"\n\n",
|
|
337
|
+
"Unlike a password, this key is never sent to the server and is entirely in your control.",
|
|
338
|
+
"If you lose this key you will lose access to your account and data.",
|
|
339
|
+
].join(' ')}
|
|
340
|
+
/>
|
|
341
|
+
</small>
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
<div>
|
|
345
|
+
|
|
346
|
+
<label style={{ textDecoration: 'underline' }}>
|
|
347
|
+
I Have Saved My Secret Key
|
|
348
|
+
</label>
|
|
349
|
+
<input
|
|
350
|
+
type="checkbox"
|
|
351
|
+
checked={secretKeySaved}
|
|
352
|
+
onChange={(e) => setSecretKeySaved(e.target.checked)}
|
|
353
|
+
/>
|
|
354
|
+
|
|
355
|
+
<button
|
|
356
|
+
disabled={!secretKeySaved}
|
|
357
|
+
className={(secretKeySaved ? 'btn btn-primary' : 'btn btn-secondary') + ' float-end'}
|
|
358
|
+
onClick={continueToApp}
|
|
359
|
+
>
|
|
360
|
+
Continue
|
|
361
|
+
</button>
|
|
362
|
+
</div>
|
|
363
|
+
</div>
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
);
|
|
367
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { computed, IDoc, ITool } from "@peers-app/peers-sdk";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { MarkdownEditorInline } from "../../components/markdown-editor/editor-inline";
|
|
4
|
+
|
|
5
|
+
export const ToolCode = (props: { tool: IDoc<ITool> }) => {
|
|
6
|
+
const { tool } = props;
|
|
7
|
+
|
|
8
|
+
let code = tool.qs.code() ?? '';
|
|
9
|
+
const toolCodeObs = computed({
|
|
10
|
+
read: () => {
|
|
11
|
+
if (!code.startsWith('```')) {
|
|
12
|
+
code = '```javascript\n' + code + '\n```';
|
|
13
|
+
}
|
|
14
|
+
return code;
|
|
15
|
+
},
|
|
16
|
+
write: (newCode: string) => {
|
|
17
|
+
code = newCode;
|
|
18
|
+
if (code.startsWith('```javascript\n')) {
|
|
19
|
+
code = code.replace('```javascript\n', '');
|
|
20
|
+
code = code.replace('\n```', '');
|
|
21
|
+
}
|
|
22
|
+
tool.qs.code(code);
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div>
|
|
28
|
+
<MarkdownEditorInline
|
|
29
|
+
value={toolCodeObs as any}
|
|
30
|
+
hideToolbar={true}
|
|
31
|
+
/>
|
|
32
|
+
</div>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Tools } from "@peers-app/peers-sdk";
|
|
3
|
+
import { LoadingIndicator } from "../../components/loading-indicator";
|
|
4
|
+
import { SaveButton } from "../../components/save-button";
|
|
5
|
+
import { ScreenTabBody, Tabs } from "../../components/tabs";
|
|
6
|
+
import { ToolCode } from "./tool-code";
|
|
7
|
+
import { ToolInfo } from "./tool-info";
|
|
8
|
+
import { ToolSchema } from "./tool-schema";
|
|
9
|
+
import { usePromise } from "../../hooks";
|
|
10
|
+
import { Input } from "../../components/input";
|
|
11
|
+
import { updateActiveTabTitle } from "../../tabs-layout/tabs-state";
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
interface IToolDetailsProps {
|
|
15
|
+
toolId: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const ToolDetails = (props: IToolDetailsProps) => {
|
|
19
|
+
const tool = usePromise(async () => {
|
|
20
|
+
const toolData = await Tools().get(props.toolId);
|
|
21
|
+
if (!toolData) return null;
|
|
22
|
+
updateActiveTabTitle(toolData.name || "Tool");
|
|
23
|
+
return Tools().initDoc(toolData);
|
|
24
|
+
}, undefined, [props.toolId]);
|
|
25
|
+
|
|
26
|
+
if (tool === null) {
|
|
27
|
+
return <div>Tool not found</div>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!tool) {
|
|
31
|
+
return <LoadingIndicator />;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function saveChanges() {
|
|
35
|
+
if (!tool) return;
|
|
36
|
+
tool.save();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className="container-fluid p-3" style={{ overflowY: 'hidden' }}>
|
|
42
|
+
|
|
43
|
+
<div className="d-flex">
|
|
44
|
+
<div>
|
|
45
|
+
<h4>
|
|
46
|
+
<i className="bi bi-tools me-2"></i>
|
|
47
|
+
</h4>
|
|
48
|
+
</div>
|
|
49
|
+
<div className="flex-grow-1">
|
|
50
|
+
<h4>
|
|
51
|
+
<Input
|
|
52
|
+
key={tool.toolId}
|
|
53
|
+
className='border border-0'
|
|
54
|
+
style={{ width: '100%', outline: 'none', backgroundColor: 'transparent' }}
|
|
55
|
+
value={tool.qs.name}
|
|
56
|
+
/>
|
|
57
|
+
</h4>
|
|
58
|
+
</div>
|
|
59
|
+
<div>
|
|
60
|
+
<SaveButton
|
|
61
|
+
key={tool.toolId}
|
|
62
|
+
onClick={saveChanges}
|
|
63
|
+
doc={tool}
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
<Tabs
|
|
70
|
+
key={tool.toolId}
|
|
71
|
+
tabs={[
|
|
72
|
+
{
|
|
73
|
+
name: 'Info', content:
|
|
74
|
+
<ScreenTabBody>
|
|
75
|
+
<ToolInfo tool={tool} />
|
|
76
|
+
</ScreenTabBody>
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'Schema', content:
|
|
80
|
+
<ScreenTabBody>
|
|
81
|
+
<ToolSchema tool={tool} />
|
|
82
|
+
</ScreenTabBody>
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'Code', content:
|
|
86
|
+
<ScreenTabBody>
|
|
87
|
+
<ToolCode tool={tool} />
|
|
88
|
+
</ScreenTabBody>
|
|
89
|
+
},
|
|
90
|
+
// {
|
|
91
|
+
// name: 'Tests', content:
|
|
92
|
+
// <ScreenTabBody>
|
|
93
|
+
// <ToolTestList toolId={tool.toolId} />
|
|
94
|
+
// </ScreenTabBody>
|
|
95
|
+
// },
|
|
96
|
+
]}
|
|
97
|
+
/>
|
|
98
|
+
|
|
99
|
+
</div>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { IDoc, ITool, observable } from "@peers-app/peers-sdk";
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { Checkbox } from "../../components/checkbox";
|
|
4
|
+
import { Input } from "../../components/input";
|
|
5
|
+
import { MarkdownEditorInline } from "../../components/markdown-editor/editor-inline";
|
|
6
|
+
|
|
7
|
+
export const ToolInfo = (props: { tool: IDoc<ITool> }) => {
|
|
8
|
+
const { tool } = props;
|
|
9
|
+
|
|
10
|
+
const [markdownUsageObs] = useState(() => observable(tool.usageDescription));
|
|
11
|
+
const [markdownDetailedObs] = useState(() => observable(tool.detailedDescription || ''));
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const sub = markdownUsageObs.subscribe(() => {
|
|
15
|
+
tool.usageDescription = markdownUsageObs();
|
|
16
|
+
});
|
|
17
|
+
const sub2 = tool.qs.name.subscribe(() => {
|
|
18
|
+
tool.name = tool.qs.name().replaceAll(/\s/g, '_').replaceAll(/[^a-zA-Z0-9_-]/g, '');
|
|
19
|
+
});
|
|
20
|
+
const sub3 = markdownDetailedObs.subscribe(() => {
|
|
21
|
+
tool.detailedDescription = markdownDetailedObs();
|
|
22
|
+
});
|
|
23
|
+
return () => {
|
|
24
|
+
sub.dispose();
|
|
25
|
+
sub2.dispose();
|
|
26
|
+
sub3.dispose();
|
|
27
|
+
}
|
|
28
|
+
}, [tool]);
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div>
|
|
33
|
+
<small>Name:</small>
|
|
34
|
+
<Input
|
|
35
|
+
value={tool.qs.name}
|
|
36
|
+
className="form-control mb-3 p-0 ps-2"
|
|
37
|
+
placeholder="Tool name"
|
|
38
|
+
title="Tool name"
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
<div>
|
|
42
|
+
<label className="form-label small mt-2 me-2">Is Assistant Runner:</label>
|
|
43
|
+
<Checkbox
|
|
44
|
+
className="form-check-input mt-2"
|
|
45
|
+
checked={tool.qs.isAssistantRunner}
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<small>Usage Description:</small>
|
|
50
|
+
<MarkdownEditorInline
|
|
51
|
+
value={markdownUsageObs}
|
|
52
|
+
/>
|
|
53
|
+
<br />
|
|
54
|
+
<small>Detailed Description:</small>
|
|
55
|
+
<MarkdownEditorInline
|
|
56
|
+
value={markdownDetailedObs}
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { FieldType, ICursorIterable, IOSchemaType, ITool, newid, observable, Tools } from "@peers-app/peers-sdk";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { Input } from '../../components/input';
|
|
4
|
+
import { LazyList } from '../../components/lazy-list';
|
|
5
|
+
import { LoadingIndicator } from '../../components/loading-indicator';
|
|
6
|
+
import { MarkdownWithMentions } from '../../components/markdown-with-mentions';
|
|
7
|
+
import { isDesktop, mainContentPath } from '../../globals';
|
|
8
|
+
import { useObservable } from '../../hooks';
|
|
9
|
+
|
|
10
|
+
export function ToolList() {
|
|
11
|
+
|
|
12
|
+
const [searchTextObs] = useState(() => observable(''));
|
|
13
|
+
const [searchText] = useObservable(searchTextObs);
|
|
14
|
+
|
|
15
|
+
const [cursorObs] = useState(() => observable<ICursorIterable<ITool>>());
|
|
16
|
+
const [cursorId] = useState(() => observable(newid()));
|
|
17
|
+
|
|
18
|
+
async function newCursor() {
|
|
19
|
+
let cursor: ICursorIterable<ITool>;
|
|
20
|
+
const _searchText = searchText.trim();
|
|
21
|
+
if (_searchText) {
|
|
22
|
+
cursor = await Tools().cursor({ name: { $matchWords: _searchText } }, { sortBy: ['-toolId'] });
|
|
23
|
+
} else {
|
|
24
|
+
cursor = await Tools().cursor(undefined, { sortBy: ['-toolId'] });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
cursorObs(cursor);
|
|
28
|
+
cursorId(newid());
|
|
29
|
+
return cursor;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const sub = searchTextObs.subscribe(() => {
|
|
34
|
+
cursorObs(undefined);
|
|
35
|
+
cursorId(newid());
|
|
36
|
+
});
|
|
37
|
+
return () => sub.dispose();
|
|
38
|
+
}, [searchText]);
|
|
39
|
+
|
|
40
|
+
async function searchSubmit(evt: React.KeyboardEvent<HTMLInputElement>) {
|
|
41
|
+
if (evt.key !== "Enter") return;
|
|
42
|
+
if (!searchText.trim()) return;
|
|
43
|
+
let toolName = searchText.trim().replace(/\s+/g, '_').replaceAll(/[^a-zA-Z0-9_]/g, '');
|
|
44
|
+
const tool = await Tools().initRecord({
|
|
45
|
+
name: toolName,
|
|
46
|
+
usageDescription: searchText.trim(),
|
|
47
|
+
detailedDescription: '',
|
|
48
|
+
inputSchema: { type: IOSchemaType.simple, fields: [{ name: 'input', type: FieldType.string, description: '' }] },
|
|
49
|
+
outputSchema: { type: IOSchemaType.simple, fields: [{ name: 'output', type: FieldType.string, description: '' }] },
|
|
50
|
+
});
|
|
51
|
+
await Tools().insert(tool);
|
|
52
|
+
mainContentPath(`tools/${tool.toolId}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function loadMore(existingTools: ITool[]): Promise<ITool[]> {
|
|
56
|
+
let moreMatches: ITool[] = [];
|
|
57
|
+
let cursor = cursorObs() || await newCursor();
|
|
58
|
+
for await (const tool of cursor) {
|
|
59
|
+
if (existingTools.find(w => w.toolId === tool.toolId)) continue;
|
|
60
|
+
moreMatches.push(tool);
|
|
61
|
+
if (searchText.length && moreMatches.length > 5) break;
|
|
62
|
+
if (moreMatches.length >= 50) break;
|
|
63
|
+
}
|
|
64
|
+
if (moreMatches.length === 0) {
|
|
65
|
+
cursorObs(undefined);
|
|
66
|
+
}
|
|
67
|
+
return moreMatches;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div className='container-fluid'>
|
|
72
|
+
<Input value={searchTextObs} className="form-control mt-3" style={{ marginBottom: "10px" }} placeholder="Search or create new tool"
|
|
73
|
+
autoFocus={isDesktop() ? true : false}
|
|
74
|
+
onKeyUp={evt => searchSubmit(evt)}
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
<div className="peers-list-container">
|
|
78
|
+
<LazyList
|
|
79
|
+
key={cursorId()}
|
|
80
|
+
loadMore={loadMore}
|
|
81
|
+
scrollThreshold={0.6}
|
|
82
|
+
renderItems={(tools) => {
|
|
83
|
+
return tools.map(tool => {
|
|
84
|
+
let markdownContent = (tool.usageDescription + '\n\n---\n\n' + (tool.detailedDescription ?? ''));
|
|
85
|
+
const maxLen = 500;
|
|
86
|
+
if (markdownContent.length > maxLen) {
|
|
87
|
+
markdownContent = markdownContent.substring(0, maxLen) + '...';
|
|
88
|
+
}
|
|
89
|
+
markdownContent = markdownContent.replace(/\n\n---\n\n$/, '');
|
|
90
|
+
return (
|
|
91
|
+
<div
|
|
92
|
+
key={tool.toolId}
|
|
93
|
+
className='container-fluid pb-4'
|
|
94
|
+
>
|
|
95
|
+
<i className="bi bi-tools"></i>
|
|
96
|
+
<a href={`#tools/${tool.toolId}`}>
|
|
97
|
+
{tool.name}
|
|
98
|
+
</a>
|
|
99
|
+
<div style={{ paddingLeft: '20px' }}>
|
|
100
|
+
<MarkdownWithMentions content={markdownContent} />
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
</div>
|
|
104
|
+
)
|
|
105
|
+
})
|
|
106
|
+
}}
|
|
107
|
+
loadingIndicator={
|
|
108
|
+
<div className="d-flex justify-content-center" style={{ height: 200 }}>
|
|
109
|
+
<LoadingIndicator />
|
|
110
|
+
</div>
|
|
111
|
+
}
|
|
112
|
+
endOfList={
|
|
113
|
+
<div className="d-flex justify-content-center" style={{ height: 200 }}>
|
|
114
|
+
{/* <span className="h3">End of List</span> */}
|
|
115
|
+
</div>
|
|
116
|
+
}
|
|
117
|
+
/>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
}
|