diff --git a/.vscode/launch.json b/.vscode/launch.json index 5d8c9333ed..44cf45ec02 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -384,7 +384,8 @@ "LAST_NAME": "AI", "PASSWORD": "password", "AVATAR_PATH": "./assets/avatar.png", - "AVATAR_CONTENT_TYPE": ".png" + "AVATAR_CONTENT_TYPE": ".png", + "OPENAI_API_KEY": "token" }, "runtimeArgs": ["--nolazy", "-r", "ts-node/register"], "sourceMaps": true, diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 345e8450ed..a5b120e96f 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -566,6 +566,9 @@ dependencies: '@rush-temp/onboard-resources': specifier: file:./projects/onboard-resources.tgz version: file:projects/onboard-resources.tgz(@types/node@20.11.19)(esbuild@0.20.1)(file-loader@6.2.0)(postcss-load-config@4.0.2)(postcss@8.4.35)(ts-node@10.9.2)(webpack@5.90.3) + '@rush-temp/openai': + specifier: file:./projects/openai.tgz + version: file:projects/openai.tgz(esbuild@0.20.1)(svelte@4.2.12)(ts-node@10.9.2)(zod@3.23.8) '@rush-temp/panel': specifier: file:./projects/panel.tgz version: file:projects/panel.tgz(@types/node@20.11.19)(esbuild@0.20.1)(postcss-load-config@4.0.2)(postcss@8.4.35)(ts-node@10.9.2) @@ -580,7 +583,7 @@ dependencies: version: file:projects/pod-account.tgz '@rush-temp/pod-ai-bot': specifier: file:./projects/pod-ai-bot.tgz - version: file:projects/pod-ai-bot.tgz(bufferutil@4.0.8)(utf-8-validate@6.0.4) + version: file:projects/pod-ai-bot.tgz(bufferutil@4.0.8)(utf-8-validate@6.0.4)(zod@3.23.8) '@rush-temp/pod-analytics-collector': specifier: file:./projects/pod-analytics-collector.tgz version: file:projects/pod-analytics-collector.tgz(bufferutil@4.0.8)(utf-8-validate@6.0.4) @@ -1664,6 +1667,9 @@ dependencies: octokit: specifier: ^3.1.1 version: 3.2.1 + openai: + specifier: ^4.56.0 + version: 4.56.0(zod@3.23.8) otp-generator: specifier: ^4.0.1 version: 4.0.1 @@ -1790,6 +1796,9 @@ dependencies: telegram: specifier: 2.22.2 version: 2.22.2 + tiktoken: + specifier: ^1.0.16 + version: 1.0.16 toposort: specifier: ^2.0.2 version: 2.0.2 @@ -1847,6 +1856,9 @@ dependencies: ws: specifier: ^8.18.0 version: 8.18.0(bufferutil@4.0.8)(utf-8-validate@6.0.4) + y-indexeddb: + specifier: ^9.0.12 + version: 9.0.12(yjs@13.6.12) y-prosemirror: specifier: ^1.2.1 version: 1.2.2(prosemirror-model@1.19.4)(y-protocols@1.0.6)(yjs@13.6.12) @@ -10283,6 +10295,13 @@ packages: - supports-color dev: false + /agentkeepalive@4.5.0: + resolution: {integrity: sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==} + engines: {node: '>= 8.0.0'} + dependencies: + humanize-ms: 1.2.1 + dev: false + /aggregate-error@3.1.0: resolution: {integrity: sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==} engines: {node: '>=8'} @@ -14767,6 +14786,10 @@ packages: webpack: 5.90.3(@swc/core@1.4.2)(esbuild@0.20.1)(webpack-cli@5.1.4) dev: false + /form-data-encoder@1.7.2: + resolution: {integrity: sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==} + dev: false + /form-data@2.5.1: resolution: {integrity: sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==} engines: {node: '>= 0.12'} @@ -14785,6 +14808,14 @@ packages: mime-types: 2.1.35 dev: false + /formdata-node@4.4.1: + resolution: {integrity: sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==} + engines: {node: '>= 12.20'} + dependencies: + node-domexception: 1.0.0 + web-streams-polyfill: 4.0.0-beta.3 + dev: false + /formdata@0.10.4: resolution: {integrity: sha512-IsHa+GYLLXHx0RmpUmzQTdwxDjNinxD+1zKOYPLaRwiqTfex5caQhOzgPIjFgJkL0O884Ers76BSHzXJxHvPLw==} dependencies: @@ -15780,6 +15811,12 @@ packages: engines: {node: '>=16.17.0'} dev: false + /humanize-ms@1.2.1: + resolution: {integrity: sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==} + dependencies: + ms: 2.1.3 + dev: false + /iconv-corefoundation@1.1.7: resolution: {integrity: sha512-T10qvkw0zz4wnm560lOEg0PovVqUXuOFhhHAkixw8/sycy7TJt7v/RrkEKEQnAw2viPSJu6iAkErxnzR0g8PpQ==} engines: {node: ^8.11.2 || >=10} @@ -18379,6 +18416,11 @@ packages: minimatch: 3.1.2 dev: false + /node-domexception@1.0.0: + resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} + engines: {node: '>=10.5.0'} + dev: false + /node-fetch-native@1.6.2: resolution: {integrity: sha512-69mtXOFZ6hSkYiXAVB5SqaRvrbITC/NPyqv7yuu/qw0nmgPyYbIMYYNIDhNtwPrzk0ptrimrLz/hhjvm4w5Z+w==} dev: false @@ -18744,6 +18786,27 @@ packages: is-wsl: 2.2.0 dev: false + /openai@4.56.0(zod@3.23.8): + resolution: {integrity: sha512-zcag97+3bG890MNNa0DQD9dGmmTWL8unJdNkulZzWRXrl+QeD+YkBI4H58rJcwErxqGK6a0jVPZ4ReJjhDGcmw==} + hasBin: true + peerDependencies: + zod: ^3.23.8 + peerDependenciesMeta: + zod: + optional: true + dependencies: + '@types/node': 18.19.17 + '@types/node-fetch': 2.6.11 + abort-controller: 3.0.0 + agentkeepalive: 4.5.0 + form-data-encoder: 1.7.2 + formdata-node: 4.4.1 + node-fetch: 2.7.0 + zod: 3.23.8 + transitivePeerDependencies: + - encoding + dev: false + /opener@1.5.2: resolution: {integrity: sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==} hasBin: true @@ -22101,6 +22164,10 @@ packages: resolution: {integrity: sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==} dev: false + /tiktoken@1.0.16: + resolution: {integrity: sha512-hRcORIGF2YlAgWx3nzrGJOrKSJwLoc81HpXmMQk89632XAgURc7IeV2FgQ2iXo9z/J96fCvpsHg2kWoHcbj9fg==} + dev: false + /timm@1.7.1: resolution: {integrity: sha512-IjZc9KIotudix8bMaBW6QvMuq64BrJWFs1+4V0lXwWGQZwH+LnX87doAYhem4caOEusRP9/g6jVDQmZ8XOk1nw==} dev: false @@ -23061,6 +23128,11 @@ packages: - supports-color dev: false + /web-streams-polyfill@4.0.0-beta.3: + resolution: {integrity: sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==} + engines: {node: '>= 14'} + dev: false + /webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} dev: false @@ -28877,6 +28949,42 @@ packages: - ts-node dev: false + file:projects/openai.tgz(esbuild@0.20.1)(svelte@4.2.12)(ts-node@10.9.2)(zod@3.23.8): + resolution: {integrity: sha512-jWsGOjlco80/7CIZ2Ogs7lCWr23lHUDQIB2hkPgYu2rbvM7iwSz5jhPjTPmR2y9gkVTSyyd9ozTo9LuxPpI6Kg==, tarball: file:projects/openai.tgz} + id: file:projects/openai.tgz + name: '@rush-temp/openai' + version: 0.0.0 + dependencies: + '@types/jest': 29.5.12 + '@types/node': 20.11.19 + '@typescript-eslint/eslint-plugin': 6.21.0(@typescript-eslint/parser@6.21.0)(eslint@8.56.0)(typescript@5.3.3) + '@typescript-eslint/parser': 6.21.0(eslint@8.56.0)(typescript@5.3.3) + eslint: 8.56.0 + eslint-config-standard-with-typescript: 40.0.0(@typescript-eslint/eslint-plugin@6.21.0)(eslint-plugin-import@2.29.1)(eslint-plugin-n@15.7.0)(eslint-plugin-promise@6.1.1)(eslint@8.56.0)(typescript@5.3.3) + eslint-plugin-import: 2.29.1(eslint@8.56.0) + eslint-plugin-n: 15.7.0(eslint@8.56.0) + eslint-plugin-promise: 6.1.1(eslint@8.56.0) + jest: 29.7.0(@types/node@20.11.19)(ts-node@10.9.2) + openai: 4.56.0(zod@3.23.8) + prettier: 3.2.5 + prettier-plugin-svelte: 3.2.2(prettier@3.2.5)(svelte@4.2.12) + tiktoken: 1.0.16 + ts-jest: 29.1.2(esbuild@0.20.1)(jest@29.7.0)(typescript@5.3.3) + typescript: 5.3.3 + transitivePeerDependencies: + - '@babel/core' + - '@jest/types' + - babel-jest + - babel-plugin-macros + - encoding + - esbuild + - node-notifier + - supports-color + - svelte + - ts-node + - zod + dev: false + file:projects/panel.tgz(@types/node@20.11.19)(esbuild@0.20.1)(postcss-load-config@4.0.2)(postcss@8.4.35)(ts-node@10.9.2): resolution: {integrity: sha512-1v1IuSTwDSjPgaZsKWG4tEUINvY3KtFNYXDHvUVkefqJm280nZg5G4QnphrKdOseOxHN7zaSq5CoVxURn1hV2g==, tarball: file:projects/panel.tgz} id: file:projects/panel.tgz @@ -29026,8 +29134,8 @@ packages: - supports-color dev: false - file:projects/pod-ai-bot.tgz(bufferutil@4.0.8)(utf-8-validate@6.0.4): - resolution: {integrity: sha512-5Upjw52FvxxuZY9eSN8N5FUKoNMhqME7DwEAp4TTQEKR/Rs+Fnxi7S5ZQ6G2G40RmZ0F0mWfXfWTcyhFlyio5Q==, tarball: file:projects/pod-ai-bot.tgz} + file:projects/pod-ai-bot.tgz(bufferutil@4.0.8)(utf-8-validate@6.0.4)(zod@3.23.8): + resolution: {integrity: sha512-/UB67RfT0fI4XW6vu6sYFLs57ciAWNBNDq5Au/5qgN1ilwh/VvgqJNgwiGTPkqt4b1Q9AKfpy7AIRy2FoAk1/A==, tarball: file:projects/pod-ai-bot.tgz} id: file:projects/pod-ai-bot.tgz name: '@rush-temp/pod-ai-bot' version: 0.0.0 @@ -29056,7 +29164,9 @@ packages: jest: 29.7.0(@types/node@20.11.19)(ts-node@10.9.2) mongodb: 6.8.0 node-fetch: 2.7.0 + openai: 4.56.0(zod@3.23.8) prettier: 3.2.5 + tiktoken: 1.0.16 ts-jest: 29.1.2(esbuild@0.20.1)(jest@29.7.0)(typescript@5.3.3) ts-node: 10.9.2(@types/node@20.11.19)(typescript@5.3.3) typescript: 5.3.3 @@ -29080,6 +29190,7 @@ packages: - socks - supports-color - utf-8-validate + - zod dev: false file:projects/pod-analytics-collector.tgz(bufferutil@4.0.8)(utf-8-validate@6.0.4): @@ -30035,7 +30146,7 @@ packages: dev: false file:projects/prod.tgz(bufferutil@4.0.8)(sass@1.71.1)(ts-node@10.9.2)(utf-8-validate@6.0.4): - resolution: {integrity: sha512-lYEzH4pmYid/iB0WNGOZXt3y9nyDbs70r3jYZJ6qIQEyvQVqWXnAd8Rw+nqcEbI/QtTou81FrvAK2Fnp5Imeww==, tarball: file:projects/prod.tgz} + resolution: {integrity: sha512-BKzsLd9ugM4rEyUkJyeMG3QjOS0RLA/ipkLIIRC+NUUQi/zMuHMEumvoSok539kpPsVgRrtJdnDBa+3tja5fSA==, tarball: file:projects/prod.tgz} id: file:projects/prod.tgz name: '@rush-temp/prod' version: 0.0.0 @@ -30932,6 +31043,7 @@ packages: '@types/node': 20.11.19 '@typescript-eslint/eslint-plugin': 6.21.0(@typescript-eslint/parser@6.21.0)(eslint@8.56.0)(typescript@5.3.3) '@typescript-eslint/parser': 6.21.0(eslint@8.56.0)(typescript@5.3.3) + bson: 6.8.0 eslint: 8.56.0 eslint-config-standard-with-typescript: 40.0.0(@typescript-eslint/eslint-plugin@6.21.0)(eslint-plugin-import@2.29.1)(eslint-plugin-n@15.7.0)(eslint-plugin-promise@6.1.1)(eslint@8.56.0)(typescript@5.3.3) eslint-plugin-import: 2.29.1(eslint@8.56.0) diff --git a/models/server-ai-bot/src/index.ts b/models/server-ai-bot/src/index.ts index d81b0c21d3..c7c8d0c999 100644 --- a/models/server-ai-bot/src/index.ts +++ b/models/server-ai-bot/src/index.ts @@ -45,7 +45,7 @@ export class TAIBotEvent extends TDoc implements AIBotEvent { message!: string } -@Model(aiBot.class.AIBotResponseEvent, core.class.Doc) +@Model(aiBot.class.AIBotResponseEvent, aiBot.class.AIBotEvent) export class TAIBotResponseEvent extends TAIBotEvent implements AIBotResponseEvent { @Prop(TypeRef(core.class.Doc), core.string.Object) objectId!: Ref diff --git a/plugins/activity-resources/src/components/Replies.svelte b/plugins/activity-resources/src/components/Replies.svelte index 177e6d8c0e..96d5199375 100644 --- a/plugins/activity-resources/src/components/Replies.svelte +++ b/plugins/activity-resources/src/components/Replies.svelte @@ -78,13 +78,13 @@ const replyProvider = client.getModel().findAllSync(activity.class.ReplyProvider, {})[0] - async function handleReply (e: MouseEvent) { + async function handleReply (e: MouseEvent): Promise { e.stopPropagation() e.preventDefault() if (replyProvider) { const fn = await getResource(replyProvider.function) - fn(object) + await fn(object) } } @@ -92,7 +92,7 @@ {#if !embedded && object.replies && object.replies > 0} -
+
{#each displayPersons as person} @@ -112,12 +112,10 @@ {#if hasNew}
{/if} -
+
-
-
+
{/if} @@ -126,24 +124,23 @@ border: 1px solid transparent; border-radius: 0.5rem; padding: 0.25rem 0.5rem; - width: fit-content; height: 2.125rem; margin-left: -0.5rem; + min-width: 14.5rem; .plus { margin-left: 0.25rem; } .repliesCount { + flex: 1; + max-width: fit-content; color: var(--theme-link-color); font-weight: 500; } - .time { - font-size: 0.75rem; - } - .lastReply { + flex: 1; font-size: 0.75rem; margin-right: 0.25rem; } diff --git a/plugins/activity-resources/src/components/reactions/Reactions.svelte b/plugins/activity-resources/src/components/reactions/Reactions.svelte index b2af83de4d..7df064d594 100644 --- a/plugins/activity-resources/src/components/reactions/Reactions.svelte +++ b/plugins/activity-resources/src/components/reactions/Reactions.svelte @@ -15,7 +15,7 @@ @@ -64,12 +66,13 @@
-
{emoji}
+ {emoji}
{accounts.length}
@@ -108,8 +111,18 @@ border: none; cursor: pointer; + &.highlight { + background: var(--global-ui-highlight-BackgroundColor); + border: 1px solid var(--global-accent-BackgroundColor); + } + &:hover { background: var(--global-ui-highlight-BackgroundColor); + border: 1px solid var(--global-popover-ShadowColor); + + &.highlight { + border: 1px solid var(--global-accent-BackgroundColor); + } } &.withoutBackground { diff --git a/plugins/chunter-resources/src/components/PinnedMessagesPopup.svelte b/plugins/chunter-resources/src/components/PinnedMessagesPopup.svelte index e15011c96f..62fd8c707a 100644 --- a/plugins/chunter-resources/src/components/PinnedMessagesPopup.svelte +++ b/plugins/chunter-resources/src/components/PinnedMessagesPopup.svelte @@ -16,7 +16,7 @@ import { createQuery, getClient } from '@hcengineering/presentation' import activity, { ActivityMessage, ActivityReference } from '@hcengineering/activity' import { ActivityMessagePresenter, sortActivityMessages } from '@hcengineering/activity-resources' - import { ActionIcon, IconClose } from '@hcengineering/ui' + import { ActionIcon, IconClose, Loading } from '@hcengineering/ui' import { createEventDispatcher } from 'svelte' import { ThreadMessage } from '@hcengineering/chunter' import { Class, Doc, Ref, SortingOrder, Space } from '@hcengineering/core' @@ -38,11 +38,18 @@ let pinnedThreads: ThreadMessage[] = [] let pinnedRefs: ActivityReference[] = [] + let isPinnedLoaded = false + let isThreadsPinnedLoaded = false + let isPinnedRefsLoaded = false + + $: isLoaded = isPinnedLoaded && isThreadsPinnedLoaded && isPinnedRefsLoaded + $: pinnedQuery.query( activity.class.ActivityMessage, { attachedTo, isPinned: true, space }, (res: ActivityMessage[]) => { pinnedMessages = res + isPinnedLoaded = true } ) @@ -51,6 +58,7 @@ { objectId: attachedTo, isPinned: true, space }, (res: ThreadMessage[]) => { pinnedThreads = res + isThreadsPinnedLoaded = true } ) @@ -60,11 +68,14 @@ { attachedTo, isPinned: true, space: { $ne: space } }, (res) => { pinnedRefs = res + isPinnedRefsLoaded = true } ) + } else { + isPinnedRefsLoaded = true } - $: if (pinnedMessages.length === 0 && pinnedThreads.length === 0) { + $: if (isLoaded && pinnedMessages.length === 0 && pinnedThreads.length === 0 && pinnedRefs.length === 0) { dispatch('close', undefined) } @@ -79,6 +90,9 @@