From fc093175168a74b1bf5d18b5d6b0434c5e91d563 Mon Sep 17 00:00:00 2001 From: Nico Arqueros Date: Mon, 30 Dec 2024 11:35:22 +0530 Subject: [PATCH 01/39] first commit --- .../vector-fs/components/vector-fs-item.tsx | 28 +++---- libs/shinkai-message-ts/src/api/methods.ts | 4 + libs/shinkai-node-state/jest.config.ts | 11 +++ .../lib/queries/getVRPathSimplified/types.ts | 48 ++--------- .../src/lib/utils/files.test.ts | 82 +++++++++++++++++++ .../shinkai-node-state/src/lib/utils/files.ts | 73 +++++++++-------- libs/shinkai-node-state/tsconfig.spec.json | 27 ++++++ 7 files changed, 185 insertions(+), 88 deletions(-) create mode 100644 libs/shinkai-node-state/jest.config.ts create mode 100644 libs/shinkai-node-state/src/lib/utils/files.test.ts create mode 100644 libs/shinkai-node-state/tsconfig.spec.json diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx index 818221123..3c7cefedc 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx @@ -29,20 +29,20 @@ import { VectorFsItemAction } from './vector-fs-drawer'; export const VectorFsItemInfo = ({ file, createdDatetime, - fileSize, + // fileSize, }: { file: VRItem; createdDatetime: string; - fileSize: string; + // fileSize: string; }) => { const layout = useVectorFsStore((state) => state.layout); return (
-
{file.name}
+
{file.path}
{layout === VectorFSLayout.List && (

- {createdDatetime} - {fileSize} + {createdDatetime} - 0

)}
@@ -77,33 +77,33 @@ const VectorFsItem = ({ layout === VectorFSLayout.Grid && 'bg-gray-400/30 p-2', ); - const createdDatetime = formatDateToUSLocaleString(file.created_datetime); - const fileSize = size(file.vr_size); + const createdDatetime = formatDateToUSLocaleString(new Date(file.created_time)); + // const fileSize = size(file.size); if (isVRSelectionActive) { return (
{ handleSelectFiles(file); }} />
@@ -112,16 +112,16 @@ const VectorFsItem = ({ return ( diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-folder.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-folder.tsx index c99261c9c..65a2d07d6 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-folder.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-folder.tsx @@ -1,6 +1,6 @@ import { DotsVerticalIcon } from '@radix-ui/react-icons'; import { useTranslation } from '@shinkai_network/shinkai-i18n'; -import { VRFolder } from '@shinkai_network/shinkai-node-state/lib/queries/getVRPathSimplified/types'; +import { DirectoryContent } from '@shinkai_network/shinkai-message-ts/api/vector-fs/types'; import { buttonVariants, Checkbox, @@ -21,7 +21,7 @@ import { DirectoryTypeIcon, SharedFolderIcon, } from '@shinkai_network/shinkai-ui/assets'; -// import { formatDateToUSLocaleString } from '@shinkai_network/shinkai-ui/helpers'; +import { formatDateToUSLocaleString } from '@shinkai_network/shinkai-ui/helpers'; import { cn } from '@shinkai_network/shinkai-ui/utils'; import { CopyIcon, @@ -43,7 +43,7 @@ export const VectorFsFolderInfo = ({ allowFolderNameOnly, layout, }: { - folder: VRFolder; + folder: DirectoryContent; totalItem?: number; allowFolderNameOnly?: boolean; layout?: VectorFSLayout; @@ -53,8 +53,10 @@ export const VectorFsFolderInfo = ({
{folder.name}
{layout === VectorFSLayout.List && !allowFolderNameOnly && (

- {/*{formatDateToUSLocaleString(folder.created_datetime)} -{' '}*/} - {totalItem} items + + {formatDateToUSLocaleString(new Date(folder.created_time ?? ''))} + {' '} + - {totalItem} items

)} @@ -69,8 +71,8 @@ const VectorFsFolder = ({ isSharedFolder, }: { onClick: () => void; - folder: VRFolder; - handleSelectFolders: (folder: VRFolder) => void; + folder: DirectoryContent; + handleSelectFolders: (folder: DirectoryContent) => void; isSelectedFolder: boolean; isSharedFolder?: boolean; }) => { @@ -91,9 +93,7 @@ const VectorFsFolder = ({ 'flex items-center justify-between gap-2 truncate rounded-lg py-3.5 pr-2 hover:bg-gradient-to-r hover:from-gray-500 hover:to-gray-400', layout === VectorFSLayout.Grid && 'bg-gray-400/30 p-2', ); - const totalItem = - // (folder.child_folders?.length ?? 0) + (folder.child_items?.length ?? 0); - 0; + const totalItem = (folder.children ?? []).length; const FolderIcon = isSharedFolder ? SharedFolderIcon : DirectoryTypeIcon; diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx index e9b26749d..c823919b6 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx @@ -1,6 +1,6 @@ import { DotsVerticalIcon } from '@radix-ui/react-icons'; import { useTranslation } from '@shinkai_network/shinkai-i18n'; -import { VRItem } from '@shinkai_network/shinkai-node-state/lib/queries/getVRPathSimplified/types'; +import { DirectoryContent } from '@shinkai_network/shinkai-message-ts/api/vector-fs/types'; import { buttonVariants, Checkbox, @@ -16,7 +16,10 @@ import { TooltipTrigger, } from '@shinkai_network/shinkai-ui'; import { CreateAIIcon, FileTypeIcon } from '@shinkai_network/shinkai-ui/assets'; -import { formatDateToUSLocaleString } from '@shinkai_network/shinkai-ui/helpers'; +import { + formatDateToUSLocaleString, + getFileExt, +} from '@shinkai_network/shinkai-ui/helpers'; import { cn } from '@shinkai_network/shinkai-ui/utils'; import { partial } from 'filesize'; import { CopyIcon, FileInputIcon, TrashIcon } from 'lucide-react'; @@ -29,11 +32,11 @@ import { VectorFsItemAction } from './vector-fs-drawer'; export const VectorFsItemInfo = ({ file, createdDatetime, - // fileSize, + fileSize, }: { - file: VRItem; + file: DirectoryContent; createdDatetime: string; - // fileSize: string; + fileSize: string; }) => { const layout = useVectorFsStore((state) => state.layout); @@ -42,7 +45,7 @@ export const VectorFsItemInfo = ({
{file.path}
{layout === VectorFSLayout.List && (

- {createdDatetime} - 0 + {createdDatetime} - {fileSize}

)} @@ -56,8 +59,8 @@ const VectorFsItem = ({ isSelectedFile, }: { onClick: () => void; - file: VRItem; - handleSelectFiles: (file: VRItem) => void; + file: DirectoryContent; + handleSelectFiles: (file: DirectoryContent) => void; isSelectedFile: boolean; }) => { const { t } = useTranslation(); @@ -80,7 +83,7 @@ const VectorFsItem = ({ const createdDatetime = formatDateToUSLocaleString( new Date(file.created_time), ); - // const fileSize = size(file.size); + const fileSize = size(file.size); if (isVRSelectionActive) { return ( @@ -96,11 +99,11 @@ const VectorFsItem = ({ className="flex flex-1 items-center gap-3" htmlFor={`item-${file.path}`} > - + @@ -109,11 +112,11 @@ const VectorFsItem = ({ return ( - ); -} diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-drawer.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-drawer.tsx index 0b4294228..aff8834fa 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-drawer.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-drawer.tsx @@ -4,10 +4,8 @@ import { useVectorFsStore } from '../context/vector-fs-context'; import { VectorFolderSelectionProvider } from './folder-selection-list'; import { VectorFsFolderCopyAction, - VectorFsFolderCreateShareableAction, VectorFsFolderDeleteAction, VectorFsFolderMoveAction, - VectorFsFolderUnshareAction, } from './vector-fs-folder-options'; import { AddNewFolderAction, @@ -65,8 +63,6 @@ export enum VectorFsFolderAction { Move = 'move-folder', Copy = 'copy-folder', Delete = 'delete-folder', - CreateShareable = 'create-shareable-folder', - Unshare = 'unshare-folder', } export enum VectorFsItemAction { @@ -103,10 +99,6 @@ const VectorFSDrawerContent = ({ return ; case VectorFsFolderAction.Delete: return ; - case VectorFsFolderAction.CreateShareable: - return ; - case VectorFsFolderAction.Unshare: - return ; // item actions case VectorFsItemAction.Move: diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-folder-options.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-folder-options.tsx index 2b42cb8dd..7a6121373 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-folder-options.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-folder-options.tsx @@ -1,31 +1,14 @@ -import { zodResolver } from '@hookform/resolvers/zod'; import { useTranslation } from '@shinkai_network/shinkai-i18n'; -import { isShinkaiIdentityLocalhost } from '@shinkai_network/shinkai-message-ts/utils'; -import { - ShareFolderFormSchema, - shareFolderFormSchema, -} from '@shinkai_network/shinkai-node-state/forms/vector-fs/folder'; -import { useCreateShareableFolder } from '@shinkai_network/shinkai-node-state/lib/mutations/createShareableFolder/useCreateShareableFolder'; -import { useUnshareFolder } from '@shinkai_network/shinkai-node-state/lib/mutations/unshareFolder/useUnshareFolder'; import { useCopyFolder } from '@shinkai_network/shinkai-node-state/v2/mutations/copyFolder/useCopyFolder'; import { useMoveFolder } from '@shinkai_network/shinkai-node-state/v2/mutations/moveFolder/useMoveFolder'; import { useRemoveFolder } from '@shinkai_network/shinkai-node-state/v2/mutations/removeFolder/useRemoveFolder'; import { - Alert, - AlertDescription, - AlertTitle, Button, - Form, - FormField, - SheetDescription, SheetFooter, SheetHeader, SheetTitle, - TextField, } from '@shinkai_network/shinkai-ui'; -import { AlertCircle } from 'lucide-react'; import React from 'react'; -import { useForm } from 'react-hook-form'; import { toast } from 'sonner'; import { useAuth } from '../../../store/auth'; @@ -199,182 +182,3 @@ export const VectorFsFolderCopyAction = () => { ); }; - -export const VectorFsFolderCreateShareableAction = () => { - const { t } = useTranslation(); - const selectedFolder = useVectorFsStore((state) => state.selectedFolder); - const closeDrawerMenu = useVectorFsStore((state) => state.closeDrawerMenu); - const auth = useAuth((state) => state.auth); - const shareFolderForm = useForm({ - resolver: zodResolver(shareFolderFormSchema), - }); - const destinationFolderPath = useVectorFolderSelectionStore( - (state) => state.destinationFolderPath, - ); - const setSelectedVectorFsTab = useVectorFsStore( - (state) => state.setSelectedVectorFsTab, - ); - - const { mutateAsync: createShareableFolder, isPending } = - useCreateShareableFolder({ - onSuccess: () => { - closeDrawerMenu(); - toast.success(t('vectorFs.success.folderShared')); - setSelectedVectorFsTab('shared-folders'); - }, - onError: () => { - toast.error(t('vectorFs.errors.folderShared')); - }, - }); - - const onSubmit = async (data: ShareFolderFormSchema) => { - await createShareableFolder({ - nodeAddress: auth?.node_address ?? '', - shinkaiIdentity: auth?.shinkai_identity ?? '', - profile: auth?.profile ?? '', - folderPath: selectedFolder?.path ?? '', - folderDescription: data.folderDescription ?? '', - my_device_encryption_sk: auth?.profile_encryption_sk ?? '', - my_device_identity_sk: auth?.profile_identity_sk ?? '', - node_encryption_pk: auth?.node_encryption_pk ?? '', - profile_encryption_sk: auth?.profile_encryption_sk ?? '', - profile_identity_sk: auth?.profile_identity_sk ?? '', - }); - }; - - const isIdentityLocalhost = isShinkaiIdentityLocalhost( - auth?.shinkai_identity ?? '', - ); - - return ( - - - - {t('vectorFs.actions.share')} - - {' '} - "{selectedFolder?.name}" - {' '} - - - {t('vectorFs.actions.shareFolderText')} - - -
- - ( - - )} - /> - - - {isIdentityLocalhost && ( - - - - {t('vectorFs.shareFolderWarning.title')} - - -
- {t('vectorFs.shareFolderWarning.text')} - - - {t('vectorFs.shareFolderWarning.action')}{' '} - -
-
-
- )} - - -
- ); -}; -export const VectorFsFolderUnshareAction = () => { - const { t, Trans } = useTranslation(); - const selectedFolder = useVectorFsStore((state) => state.selectedFolder); - const closeDrawerMenu = useVectorFsStore((state) => state.closeDrawerMenu); - const auth = useAuth((state) => state.auth); - const destinationFolderPath = useVectorFolderSelectionStore( - (state) => state.destinationFolderPath, - ); - - const { mutateAsync: unshareFolder, isPending } = useUnshareFolder({ - onSuccess: () => { - closeDrawerMenu(); - toast.success(t('vectorFs.success.folderUnshared')); - }, - onError: () => { - toast.error(t('vectorFs.errors.folderUnshared')); - }, - }); - - return ( - - - - {t('vectorFs.actions.unshare')} - - {' '} - "{selectedFolder?.name}" - {' '} - ? - - - }} - i18nKey="vectorFs.actions.unshareFolderText" - /> - - - - - - - - ); -}; diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-folder.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-folder.tsx index 65a2d07d6..e8c55654d 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-folder.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-folder.tsx @@ -23,17 +23,10 @@ import { } from '@shinkai_network/shinkai-ui/assets'; import { formatDateToUSLocaleString } from '@shinkai_network/shinkai-ui/helpers'; import { cn } from '@shinkai_network/shinkai-ui/utils'; -import { - CopyIcon, - FolderInputIcon, - Link2Off, - Share2, - TrashIcon, -} from 'lucide-react'; +import { CopyIcon, FolderInputIcon, TrashIcon } from 'lucide-react'; import React from 'react'; import { useNavigate } from 'react-router-dom'; -import config from '../../../config'; import { useVectorFsStore, VectorFSLayout } from '../context/vector-fs-context'; import { VectorFsFolderAction } from './vector-fs-drawer'; @@ -212,24 +205,6 @@ const VectorFsFolder = ({ }); }, }, - config.isDev && - (isSharedFolder - ? { - name: t('vectorFs.actions.unshare'), - icon: , - onClick: () => { - setActiveDrawerMenuOption(VectorFsFolderAction.Unshare); - }, - } - : { - name: t('vectorFs.actions.share'), - icon: , - onClick: () => { - setActiveDrawerMenuOption( - VectorFsFolderAction.CreateShareable, - ); - }, - }), { name: t('vectorFs.actions.delete'), icon: , diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item-detail.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item-detail.tsx index c03db7149..c8eb556df 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item-detail.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item-detail.tsx @@ -11,6 +11,7 @@ import { FileTypeIcon } from '@shinkai_network/shinkai-ui/assets'; import { formatDateToLocaleStringWithTime, formatDateToUSLocaleString, + getFileExt, } from '@shinkai_network/shinkai-ui/helpers'; import { save } from '@tauri-apps/plugin-dialog'; import { BaseDirectory } from '@tauri-apps/plugin-fs'; @@ -28,9 +29,8 @@ export const VectorFileDetails = () => { const size = partial({ standard: 'jedec' }); const auth = useAuth((state) => state.auth); - const fileExtension = - selectedFile?.vr_header?.resource_source?.Standard?.FileRef?.file_type - ?.Document; + const fileExtension = getFileExt(selectedFile?.name ?? ''); + const { mutateAsync: retreiveSourceFile } = useRetrieveSourceFile({ onSuccess: async (response, variables) => { if (!fileExtension) { @@ -100,25 +100,22 @@ export const VectorFileDetails = () => {

{selectedFile?.name} - {selectedFile?.vr_header?.resource_source?.Standard?.FileRef - ?.file_type?.Document ?? '-'} + {getFileExt(selectedFile?.name ?? '') ?? '-'}

- {formatDateToUSLocaleString(selectedFile?.created_datetime)} + {formatDateToUSLocaleString( + new Date(selectedFile?.created_time ?? ''), + )} {' '} - -{' '} - {size(selectedFile?.vr_size ?? 0)} + - {size(selectedFile?.size ?? 0)}

@@ -127,14 +124,14 @@ export const VectorFileDetails = () => {
{[ - { label: 'Created', value: selectedFile?.created_datetime }, + { label: 'Created', value: selectedFile?.created_time }, { label: 'Modified', - value: selectedFile?.last_written_datetime, + value: selectedFile?.modified_time, }, { label: 'Last Opened', - value: selectedFile?.last_read_datetime, + value: selectedFile?.modified_time, }, ].map((item) => (
{ > {item.label} - {formatDateToLocaleStringWithTime(item.value)} + {formatDateToLocaleStringWithTime(new Date(item.value ?? ''))}
))} diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx index c823919b6..e16e5f0ee 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx @@ -42,7 +42,7 @@ export const VectorFsItemInfo = ({ return (
-
{file.path}
+
{file.name}
{layout === VectorFSLayout.List && (

{createdDatetime} - {fileSize} diff --git a/apps/shinkai-desktop/src/components/vector-fs/vector-fs.tsx b/apps/shinkai-desktop/src/components/vector-fs/vector-fs.tsx index 1c6d2741e..513571302 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/vector-fs.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/vector-fs.tsx @@ -1,53 +1,15 @@ import { useTranslation } from '@shinkai_network/shinkai-i18n'; -import { - Tabs, - TabsContent, - TabsList, - TabsTrigger, -} from '@shinkai_network/shinkai-ui'; import { SimpleLayout } from '../../pages/layout/simple-layout'; import AllFilesTab from './components/all-files-tab'; -import MySharedFolders from './components/my-shared-folders'; import VectorFSDrawer from './components/vector-fs-drawer'; -import { useVectorFsStore } from './context/vector-fs-context'; export default function VectorFs() { const { t } = useTranslation(); - const selectedVectorFsTab = useVectorFsStore( - (state) => state.selectedVectorFsTab, - ); - const setSelectedVectorFsTab = useVectorFsStore( - (state) => state.setSelectedVectorFsTab, - ); return ( - - setSelectedVectorFsTab(value as 'all' | 'shared-folders') - } - value={selectedVectorFsTab} - > - - - {t('vectorFs.allFiles')} - - - {t('vectorFs.sharedFolders')}{' '} - - - - - - - - - + ); diff --git a/apps/shinkai-visor/src/components/node-files/vector-fs-drawer.tsx b/apps/shinkai-visor/src/components/node-files/vector-fs-drawer.tsx index bedd5f0d0..8b0dee9c9 100644 --- a/apps/shinkai-visor/src/components/node-files/vector-fs-drawer.tsx +++ b/apps/shinkai-visor/src/components/node-files/vector-fs-drawer.tsx @@ -10,10 +10,8 @@ import { VectorFolderSelectionProvider } from './folder-selection-list'; import { useVectorFsStore } from './node-file-context'; import { VectorFsFolderCopyAction, - VectorFsFolderCreateShareableAction, VectorFsFolderDeleteAction, VectorFsFolderMoveAction, - VectorFsFolderUnshareAction, } from './vector-fs-folder-options'; import { AddNewFolderAction, @@ -74,8 +72,6 @@ export enum VectorFsFolderAction { Move = 'move-folder', Copy = 'copy-folder', Delete = 'delete-folder', - CreateShareable = 'create-shareable-folder', - Unshare = 'unshare-folder', } export enum VectorFsItemAction { @@ -112,10 +108,6 @@ const VectorFSDrawerContent = ({ return ; case VectorFsFolderAction.Delete: return ; - case VectorFsFolderAction.CreateShareable: - return ; - case VectorFsFolderAction.Unshare: - return ; // item actions case VectorFsItemAction.Move: diff --git a/apps/shinkai-visor/src/components/node-files/vector-fs-folder-options.tsx b/apps/shinkai-visor/src/components/node-files/vector-fs-folder-options.tsx index ad225ad04..59b719aa6 100644 --- a/apps/shinkai-visor/src/components/node-files/vector-fs-folder-options.tsx +++ b/apps/shinkai-visor/src/components/node-files/vector-fs-folder-options.tsx @@ -1,31 +1,14 @@ -import { zodResolver } from '@hookform/resolvers/zod'; import { useTranslation } from '@shinkai_network/shinkai-i18n'; -import { isShinkaiIdentityLocalhost } from '@shinkai_network/shinkai-message-ts/utils'; -import { - ShareFolderFormSchema, - shareFolderFormSchema, -} from '@shinkai_network/shinkai-node-state/forms/vector-fs/folder'; -import { useCreateShareableFolder } from '@shinkai_network/shinkai-node-state/lib/mutations/createShareableFolder/useCreateShareableFolder'; -import { useUnshareFolder } from '@shinkai_network/shinkai-node-state/lib/mutations/unshareFolder/useUnshareFolder'; import { useCopyFolder } from '@shinkai_network/shinkai-node-state/v2/mutations/copyFolder/useCopyFolder'; import { useMoveFolder } from '@shinkai_network/shinkai-node-state/v2/mutations/moveFolder/useMoveFolder'; import { useRemoveFolder } from '@shinkai_network/shinkai-node-state/v2/mutations/removeFolder/useRemoveFolder'; import { - Alert, - AlertDescription, - AlertTitle, Button, - DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, - Form, - FormField, - TextField, } from '@shinkai_network/shinkai-ui'; -import { AlertCircle } from 'lucide-react'; import React from 'react'; -import { useForm } from 'react-hook-form'; import { toast } from 'sonner'; import { useAuth } from '../../store/auth/auth'; @@ -198,180 +181,3 @@ export const VectorFsFolderCopyAction = () => { ); }; - -export const VectorFsFolderCreateShareableAction = () => { - const { t } = useTranslation(); - const selectedFolder = useVectorFsStore((state) => state.selectedFolder); - const closeDrawerMenu = useVectorFsStore((state) => state.closeDrawerMenu); - const auth = useAuth((state) => state.auth); - const shareFolderForm = useForm({ - resolver: zodResolver(shareFolderFormSchema), - }); - const destinationFolderPath = useVectorFolderSelectionStore( - (state) => state.destinationFolderPath, - ); - const setSelectedVectorFsTab = useVectorFsStore( - (state) => state.setSelectedVectorFsTab, - ); - - const { mutateAsync: createShareableFolder, isPending } = - useCreateShareableFolder({ - onSuccess: () => { - closeDrawerMenu(); - toast.success(t('vectorFs.success.folderShared')); - setSelectedVectorFsTab('shared-folders'); - }, - onError: () => { - toast.error(t('vectorFs.errors.folderShared')); - }, - }); - - const onSubmit = async (data: ShareFolderFormSchema) => { - await createShareableFolder({ - nodeAddress: auth?.node_address ?? '', - shinkaiIdentity: auth?.shinkai_identity ?? '', - profile: auth?.profile ?? '', - folderPath: selectedFolder?.path ?? '', - folderDescription: data.folderDescription ?? '', - my_device_encryption_sk: auth?.profile_encryption_sk ?? '', - my_device_identity_sk: auth?.profile_identity_sk ?? '', - node_encryption_pk: auth?.node_encryption_pk ?? '', - profile_encryption_sk: auth?.profile_encryption_sk ?? '', - profile_identity_sk: auth?.profile_identity_sk ?? '', - }); - }; - const isIdentityLocalhost = isShinkaiIdentityLocalhost( - auth?.shinkai_identity ?? '', - ); - - return ( - - - - {t('vectorFs.actions.share')} - - {' '} - "{selectedFolder?.name}" - {' '} - - - {t('vectorFs.actions.shareFolderText')} - - -

- - ( - - )} - /> - - - {isIdentityLocalhost && ( - - - - {t('vectorFs.shareFolderWarning.title')} - - -
- {t('vectorFs.shareFolderWarning.text')} - - {t('vectorFs.shareFolderWarning.action')}{' '} - -
-
-
- )} - - - - ); -}; -export const VectorFsFolderUnshareAction = () => { - const { t, Trans } = useTranslation(); - const selectedFolder = useVectorFsStore((state) => state.selectedFolder); - const closeDrawerMenu = useVectorFsStore((state) => state.closeDrawerMenu); - const auth = useAuth((state) => state.auth); - const destinationFolderPath = useVectorFolderSelectionStore( - (state) => state.destinationFolderPath, - ); - - const { mutateAsync: unshareFolder, isPending } = useUnshareFolder({ - onSuccess: () => { - closeDrawerMenu(); - toast.success(t('vectorFs.success.folderUnshared')); - }, - onError: () => { - toast.error(t('vectorFs.errors.folderUnshared')); - }, - }); - - return ( - - - - {t('vectorFs.actions.unshare')} - - {' '} - "{selectedFolder?.name}" - {' '} - ? - - - }} - i18nKey="vectorFs.actions.unshareFolderText" - /> - - - - - - - - ); -}; diff --git a/apps/shinkai-visor/src/components/node-files/vector-fs-folder.tsx b/apps/shinkai-visor/src/components/node-files/vector-fs-folder.tsx index 93c40e0ad..ae64900bb 100644 --- a/apps/shinkai-visor/src/components/node-files/vector-fs-folder.tsx +++ b/apps/shinkai-visor/src/components/node-files/vector-fs-folder.tsx @@ -1,6 +1,6 @@ import { DotsVerticalIcon } from '@radix-ui/react-icons'; import { useTranslation } from '@shinkai_network/shinkai-i18n'; -import { VRFolder } from '@shinkai_network/shinkai-node-state/lib/queries/getVRPathSimplified/types'; +import { DirectoryContent } from '@shinkai_network/shinkai-message-ts/api/vector-fs/types'; import { buttonVariants, Checkbox, @@ -17,17 +17,10 @@ import { } from '@shinkai_network/shinkai-ui/assets'; import { formatDateToUSLocaleString } from '@shinkai_network/shinkai-ui/helpers'; import { cn } from '@shinkai_network/shinkai-ui/utils'; -import { - CopyIcon, - FolderInputIcon, - Link2Off, - Share2, - TrashIcon, -} from 'lucide-react'; +import { CopyIcon, FolderInputIcon, TrashIcon } from 'lucide-react'; import React from 'react'; import { useNavigate } from 'react-router-dom'; -import config from '../../config'; import { useVectorFsStore, VectorFSLayout } from './node-file-context'; import { VectorFsFolderAction } from './vector-fs-drawer'; @@ -37,7 +30,7 @@ export const VectorFsFolderInfo = ({ allowFolderNameOnly, layout, }: { - folder: VRFolder; + folder: DirectoryContent; totalItem?: number; allowFolderNameOnly?: boolean; layout?: VectorFSLayout; @@ -47,8 +40,10 @@ export const VectorFsFolderInfo = ({
{folder.name}
{layout === VectorFSLayout.List && !allowFolderNameOnly && (

- {formatDateToUSLocaleString(folder.created_datetime)} -{' '} - {totalItem} items + + {formatDateToUSLocaleString(new Date(folder.created_time ?? ''))} + {' '} + - {totalItem} items

)}
@@ -63,8 +58,8 @@ const VectorFsFolder = ({ isSharedFolder, }: { onClick: () => void; - folder: VRFolder; - handleSelectFolders: (folder: VRFolder) => void; + folder: DirectoryContent; + handleSelectFolders: (folder: DirectoryContent) => void; isSelectedFolder: boolean; isSharedFolder?: boolean; }) => { @@ -85,8 +80,7 @@ const VectorFsFolder = ({ 'flex items-center justify-between gap-2 truncate rounded-lg py-3.5 pr-2 hover:bg-gradient-to-r hover:from-gray-500 hover:to-gray-400', layout === VectorFSLayout.Grid && 'bg-gray-400/30 p-2', ); - const totalItem = - (folder.child_folders?.length ?? 0) + (folder.child_items?.length ?? 0); + const totalItem = (folder.children ?? [])?.length ?? 0; const FolderIcon = isSharedFolder ? SharedFolderIcon : DirectoryTypeIcon; @@ -173,24 +167,6 @@ const VectorFsFolder = ({ }); }, }, - config.isDev && - (isSharedFolder - ? { - name: t('vectorFs.actions.unshare'), - icon: , - onClick: () => { - setActiveDrawerMenuOption(VectorFsFolderAction.Unshare); - }, - } - : { - name: t('vectorFs.actions.share'), - icon: , - onClick: () => { - setActiveDrawerMenuOption( - VectorFsFolderAction.CreateShareable, - ); - }, - }), { name: t('vectorFs.actions.delete'), icon: , diff --git a/libs/shinkai-message-ts/src/api/jobs/types.ts b/libs/shinkai-message-ts/src/api/jobs/types.ts index 98ac1fc16..e340cacc1 100644 --- a/libs/shinkai-message-ts/src/api/jobs/types.ts +++ b/libs/shinkai-message-ts/src/api/jobs/types.ts @@ -1,73 +1,5 @@ import { AgentInbox } from '../../models/ShinkaiMessage'; -type ResourceSource = { - Standard: { - FileRef: { - file_name: string; - file_type: { - Document: string; - }; - original_creation_datetime: null; - text_chunking_strategy: string; - }; - }; -}; - -type ResourceKeywords = { - keyword_list: string[]; - keywords_embedding: null; -}; - -type VRHeader = { - resource_name: string; - resource_id: string; - resource_base_type: 'Document'; - resource_source: ResourceSource; - resource_embedding: null; - resource_created_datetime: Date; - resource_last_written_datetime: Date; - resource_embedding_model_used: { - TextEmbeddingsInference: string; - }; - resource_merkle_root: string; - resource_keywords: ResourceKeywords; - data_tag_names: string[]; - metadata_index_keys: string[]; -}; - -export type VRItem = { - name: string; - path: string; - vr_header: VRHeader; - created_datetime: Date; - last_written_datetime: Date; - last_read_datetime: Date; - vr_last_saved_datetime: Date; - source_file_map_last_saved_datetime: Date; - distribution_origin: null; - vr_size: number; - source_file_map_size: number; - merkle_hash: string; -}; - -export type VRFolder = { - path: string; - child_folders: VRFolder[]; - child_items: Array; - created_datetime: Date; - last_written_datetime: Date; - merkle_root: string; - last_modified_datetime: Date; - last_read_datetime: Date; - merkle_hash: string; - name: string; -}; - -export type VRFolderScope = Pick; -export type VRItemScope = Pick & { - source: ResourceSource; -}; - export enum VectorSearchMode { FillUpTo25k = 'FillUpTo25k', MergeSiblings = 'MergeSiblings', @@ -158,6 +90,7 @@ export type ChatMessage = { export type GetLastMessagesResponse = ChatMessage[]; export type GetLastMessagesWithBranchesResponse = ChatMessage[][]; export type CreateFilesInboxResponse = string; + export type AddFileToInboxRequest = { file_inbox_name: string; filename: string; diff --git a/libs/shinkai-message-ts/src/api/methods.ts b/libs/shinkai-message-ts/src/api/methods.ts index 6aeacef51..746f57a14 100644 --- a/libs/shinkai-message-ts/src/api/methods.ts +++ b/libs/shinkai-message-ts/src/api/methods.ts @@ -671,121 +671,6 @@ export const getAvailableSharedFolders = async ( return data; }; -// TODO: remove this -export const getMySharedFolders = async ( - nodeAddress: string, - sender: string, - sender_subidentity: string, - receiver: string, - receiver_subidentity: string, - streamer_node_name: string, - streamer_profile_name: string, - setupDetailsState: CredentialsPayload, -): Promise<{ data: any; status: string }> => { - const messageStr = ShinkaiMessageBuilderWrapper.getMySharedFolders( - setupDetailsState.profile_encryption_sk, - setupDetailsState.profile_identity_sk, - setupDetailsState.node_encryption_pk, - sender, - sender_subidentity, - receiver, - receiver_subidentity, - streamer_node_name, - streamer_profile_name, - ); - - const message = JSON.parse(messageStr); - - const response = await httpClient.post( - urlJoin(nodeAddress, '/v1/available_shared_items'), - message, - - { - responseType: 'json', - }, - ); - - const data = response.data; - return typeof data?.data === 'string' - ? { - data: JSON.parse(data.data), - status: data.status, - } - : data; -}; - -export const createShareableFolder = async ( - nodeAddress: string, - sender: string, - sender_subidentity: string, - receiver: string, - receiver_subidentity: string, - folderPath: string, - folderDescription: string, - setupDetailsState: CredentialsPayload, -): Promise<{ data: any; status: string }> => { - const messageStr = ShinkaiMessageBuilderWrapper.createShareableFolder( - setupDetailsState.profile_encryption_sk, - setupDetailsState.profile_identity_sk, - setupDetailsState.node_encryption_pk, - folderPath, - folderDescription, - sender, - sender_subidentity, - receiver, - receiver_subidentity, - ); - - const message = JSON.parse(messageStr); - - const response = await httpClient.post( - urlJoin(nodeAddress, '/v1/create_shareable_folder'), - message, - - { - responseType: 'json', - }, - ); - - const data = response.data; - return data; -}; - -// TODO: remove this -export const unshareFolder = async ( - nodeAddress: string, - sender: string, - sender_subidentity: string, - receiver: string, - receiver_subidentity: string, - folderPath: string, - setupDetailsState: CredentialsPayload, -): Promise<{ data: any; status: string }> => { - const messageStr = ShinkaiMessageBuilderWrapper.unshareFolder( - setupDetailsState.profile_encryption_sk, - setupDetailsState.profile_identity_sk, - setupDetailsState.node_encryption_pk, - folderPath, - sender, - sender_subidentity, - receiver, - receiver_subidentity, - ); - - const message = JSON.parse(messageStr); - - const response = await httpClient.post( - urlJoin(nodeAddress, '/v1/unshare_folder'), - message, - - { - responseType: 'json', - }, - ); - - const data = response.data; - return data; -}; export const subscribeToSharedFolder = async ( nodeAddress: string, sender: string, diff --git a/libs/shinkai-node-state/src/lib/mutations/createShareableFolder/index.ts b/libs/shinkai-node-state/src/lib/mutations/createShareableFolder/index.ts deleted file mode 100644 index ae399f078..000000000 --- a/libs/shinkai-node-state/src/lib/mutations/createShareableFolder/index.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { createShareableFolder as createShareableFolderAPI } from '@shinkai_network/shinkai-message-ts/api'; - -import { CreateShareableFolderInput } from './types'; - -export const createShareableFolder = async ({ - nodeAddress, - shinkaiIdentity, - profile, - folderPath, - folderDescription, - my_device_encryption_sk, - my_device_identity_sk, - node_encryption_pk, - profile_encryption_sk, - profile_identity_sk, -}: CreateShareableFolderInput) => { - return await createShareableFolderAPI( - nodeAddress, - shinkaiIdentity, - profile, - shinkaiIdentity, - profile, - folderPath, - folderDescription, - { - my_device_encryption_sk, - my_device_identity_sk, - node_encryption_pk, - profile_encryption_sk, - profile_identity_sk, - }, - ); -}; diff --git a/libs/shinkai-node-state/src/lib/mutations/createShareableFolder/types.ts b/libs/shinkai-node-state/src/lib/mutations/createShareableFolder/types.ts deleted file mode 100644 index f84c99e77..000000000 --- a/libs/shinkai-node-state/src/lib/mutations/createShareableFolder/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { CredentialsPayload } from '@shinkai_network/shinkai-message-ts/models'; - -export type CreateShareableFolderOutput = { - status: string; -}; - -export type CreateShareableFolderInput = CredentialsPayload & { - nodeAddress: string; - shinkaiIdentity: string; - profile: string; - folderPath: string; - folderDescription: string; -}; diff --git a/libs/shinkai-node-state/src/lib/mutations/createShareableFolder/useCreateShareableFolder.ts b/libs/shinkai-node-state/src/lib/mutations/createShareableFolder/useCreateShareableFolder.ts deleted file mode 100644 index 76c760ceb..000000000 --- a/libs/shinkai-node-state/src/lib/mutations/createShareableFolder/useCreateShareableFolder.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { - useMutation, - type UseMutationOptions, - useQueryClient, -} from '@tanstack/react-query'; - -import { FunctionKey } from '../../constants'; -import { createShareableFolder } from './index'; -import { - CreateShareableFolderInput, - CreateShareableFolderOutput, -} from './types'; - -type Options = UseMutationOptions< - CreateShareableFolderOutput, - Error, - CreateShareableFolderInput ->; - -export const useCreateShareableFolder = (options?: Options) => { - const queryClient = useQueryClient(); - return useMutation({ - mutationFn: createShareableFolder, - ...options, - onSuccess: (response, variables, context) => { - queryClient.invalidateQueries({ - queryKey: [FunctionKey.GET_AVAILABLE_SHARED_ITEMS], - }); - - if (options?.onSuccess) { - options.onSuccess(response, variables, context); - } - }, - }); -}; diff --git a/libs/shinkai-node-state/src/lib/mutations/unshareFolder/index.ts b/libs/shinkai-node-state/src/lib/mutations/unshareFolder/index.ts deleted file mode 100644 index 759a41ce0..000000000 --- a/libs/shinkai-node-state/src/lib/mutations/unshareFolder/index.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { unshareFolder as unshareFolderAPI } from '@shinkai_network/shinkai-message-ts/api'; - -import { UnshareFolderInput } from './types'; - -export const unshareFolder = async ({ - nodeAddress, - shinkaiIdentity, - profile, - folderPath, - my_device_encryption_sk, - my_device_identity_sk, - node_encryption_pk, - profile_encryption_sk, - profile_identity_sk, -}: UnshareFolderInput) => { - return await unshareFolderAPI( - nodeAddress, - shinkaiIdentity, - profile, - shinkaiIdentity, - profile, - folderPath, - { - my_device_encryption_sk, - my_device_identity_sk, - node_encryption_pk, - profile_encryption_sk, - profile_identity_sk, - }, - ); -}; diff --git a/libs/shinkai-node-state/src/lib/mutations/unshareFolder/types.ts b/libs/shinkai-node-state/src/lib/mutations/unshareFolder/types.ts deleted file mode 100644 index 2bc8c8dd7..000000000 --- a/libs/shinkai-node-state/src/lib/mutations/unshareFolder/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { CredentialsPayload } from '@shinkai_network/shinkai-message-ts/models'; - -export type UnshareFolderOutput = { - status: string; -}; - -export type UnshareFolderInput = CredentialsPayload & { - nodeAddress: string; - shinkaiIdentity: string; - profile: string; - folderPath: string; -}; diff --git a/libs/shinkai-node-state/src/lib/mutations/unshareFolder/useUnshareFolder.ts b/libs/shinkai-node-state/src/lib/mutations/unshareFolder/useUnshareFolder.ts deleted file mode 100644 index 774491915..000000000 --- a/libs/shinkai-node-state/src/lib/mutations/unshareFolder/useUnshareFolder.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { - useMutation, - type UseMutationOptions, - useQueryClient, -} from '@tanstack/react-query'; - -import { FunctionKey } from '../../constants'; -import { unshareFolder } from './index'; -import { UnshareFolderInput, UnshareFolderOutput } from './types'; - -type Options = UseMutationOptions< - UnshareFolderOutput, - Error, - UnshareFolderInput ->; - -export const useUnshareFolder = (options?: Options) => { - const queryClient = useQueryClient(); - return useMutation({ - mutationFn: unshareFolder, - ...options, - onSuccess: (response, variables, context) => { - queryClient.invalidateQueries({ - queryKey: [FunctionKey.GET_MY_SHARED_FOLDERS], - }); - - if (options?.onSuccess) { - options.onSuccess(response, variables, context); - } - }, - }); -}; From 7f4210eaaac483983d9715a3e900fa94614229e3 Mon Sep 17 00:00:00 2001 From: paulclindo Date: Thu, 2 Jan 2025 18:39:17 -0500 Subject: [PATCH 20/39] fixes to download source file --- .../components/vector-fs-item-detail.tsx | 96 +++++++++---------- libs/shinkai-message-ts/src/api/jobs/index.ts | 10 +- libs/shinkai-message-ts/src/api/jobs/types.ts | 5 + .../src/api/vector-fs/index.ts | 18 ---- .../src/api/vector-fs/types.ts | 6 -- .../src/lib/mutations/downloadVRFile/index.ts | 31 ------ .../src/lib/mutations/downloadVRFile/types.ts | 13 --- .../downloadVRFile/useDownloadVRFile.ts | 17 ---- .../v2/mutations/retrieveSourceFile/index.ts | 13 --- .../v2/mutations/retrieveSourceFile/types.ts | 9 -- .../useRetrieveSourceFile.ts | 18 ---- .../v2/queries/getChatConversation/index.ts | 14 ++- .../src/v2/queries/getDownloadFile/index.ts | 11 +++ .../src/v2/queries/getDownloadFile/types.ts | 8 ++ .../getDownloadFile/useGetDownloadFile.ts | 17 ++++ 15 files changed, 101 insertions(+), 185 deletions(-) delete mode 100644 libs/shinkai-node-state/src/lib/mutations/downloadVRFile/index.ts delete mode 100644 libs/shinkai-node-state/src/lib/mutations/downloadVRFile/types.ts delete mode 100644 libs/shinkai-node-state/src/lib/mutations/downloadVRFile/useDownloadVRFile.ts delete mode 100644 libs/shinkai-node-state/src/v2/mutations/retrieveSourceFile/index.ts delete mode 100644 libs/shinkai-node-state/src/v2/mutations/retrieveSourceFile/types.ts delete mode 100644 libs/shinkai-node-state/src/v2/mutations/retrieveSourceFile/useRetrieveSourceFile.ts create mode 100644 libs/shinkai-node-state/src/v2/queries/getDownloadFile/index.ts create mode 100644 libs/shinkai-node-state/src/v2/queries/getDownloadFile/types.ts create mode 100644 libs/shinkai-node-state/src/v2/queries/getDownloadFile/useGetDownloadFile.ts diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item-detail.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item-detail.tsx index c8eb556df..a3000a565 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item-detail.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item-detail.tsx @@ -1,5 +1,4 @@ -import { useDownloadVRFile } from '@shinkai_network/shinkai-node-state/lib/mutations/downloadVRFile/useDownloadVRFile'; -import { useRetrieveSourceFile } from '@shinkai_network/shinkai-node-state/v2/mutations/retrieveSourceFile/useRetrieveSourceFile'; +import { useGetDownloadFile } from '@shinkai_network/shinkai-node-state/v2/queries/getDownloadFile/useGetDownloadFile'; import { Badge, Button, @@ -31,7 +30,7 @@ export const VectorFileDetails = () => { const fileExtension = getFileExt(selectedFile?.name ?? ''); - const { mutateAsync: retreiveSourceFile } = useRetrieveSourceFile({ + const { mutateAsync: downloadFile } = useGetDownloadFile({ onSuccess: async (response, variables) => { if (!fileExtension) { toast.error('File extension not found'); @@ -43,7 +42,7 @@ export const VectorFileDetails = () => { ); const savePath = await save({ - defaultPath: `${variables.filePath.split('/').pop()}.${fileExtension.toLowerCase()}`, + defaultPath: `${variables.path.split('/').pop()}.${fileExtension.toLowerCase()}`, filters: [ { name: fileExtension, extensions: [fileExtension.toLowerCase()] }, ], @@ -66,29 +65,29 @@ export const VectorFileDetails = () => { }, }); - const { mutateAsync: downloadVRFile } = useDownloadVRFile({ - onSuccess: async (response, variables) => { - const file = new Blob([response.data], { - type: 'application/octet-stream', - }); - const dataUrl = await new Promise((resolve) => { - const reader = new FileReader(); - reader.onload = () => resolve(reader.result as string); - reader.readAsDataURL(file); - }); - - const path = await save({ - defaultPath: variables.path.split('/').at(-1) + '.vrkai', - }); - if (!path) return; - const fileContent = await fetch(dataUrl).then((response) => - response.arrayBuffer(), - ); - await fs.writeFile(path, new Uint8Array(fileContent), { - baseDir: BaseDirectory.Download, - }); - }, - }); + // const { mutateAsync: downloadVRFile } = useDownloadVRFile({ + // onSuccess: async (response, variables) => { + // const file = new Blob([response.data], { + // type: 'application/octet-stream', + // }); + // const dataUrl = await new Promise((resolve) => { + // const reader = new FileReader(); + // reader.onload = () => resolve(reader.result as string); + // reader.readAsDataURL(file); + // }); + // + // const path = await save({ + // defaultPath: variables.path.split('/').at(-1) + '.vrkai', + // }); + // if (!path) return; + // const fileContent = await fetch(dataUrl).then((response) => + // response.arrayBuffer(), + // ); + // await fs.writeFile(path, new Uint8Array(fileContent), { + // baseDir: BaseDirectory.Download, + // }); + // }, + // }); return ( @@ -155,32 +154,33 @@ export const VectorFileDetails = () => {
+ {/* Hide it til we support it in the node */} + {/* {*/} + {/* if (!selectedFile || !auth) return;*/} + {/* await downloadVRFile({*/} + {/* nodeAddress: auth.node_address,*/} + {/* shinkaiIdentity: auth?.shinkai_identity,*/} + {/* profile: auth.profile,*/} + {/* path: selectedFile.path,*/} + {/* my_device_encryption_sk: auth.profile_encryption_sk,*/} + {/* my_device_identity_sk: auth.profile_identity_sk,*/} + {/* node_encryption_pk: auth.node_encryption_pk,*/} + {/* profile_encryption_sk: auth.profile_encryption_sk,*/} + {/* profile_identity_sk: auth.profile_identity_sk,*/} + {/* });*/} + {/* }}*/} + {/* size="sm"*/} + {/* variant="outline"*/} + {/*>*/} + {/* Download Vector Resource*/} + {/**/} - + + + + ); +}; diff --git a/libs/shinkai-i18n/src/lib/default/index.ts b/libs/shinkai-i18n/src/lib/default/index.ts index 475444610..97183fff3 100644 --- a/libs/shinkai-i18n/src/lib/default/index.ts +++ b/libs/shinkai-i18n/src/lib/default/index.ts @@ -141,6 +141,7 @@ export default { addNew: 'Add New', createFolder: 'Add New Folder', uploadFile: 'File Upload', + createTextFile: 'Create Text File', share: 'Share', unshare: 'Unshare', move: 'Move', @@ -157,6 +158,7 @@ export default { forms: { folderName: 'Folder Name', folderDescription: 'Folder Description', + textFileName: 'Title', }, pending: { filesUploading: 'Uploading files', diff --git a/libs/shinkai-node-state/src/forms/vector-fs/folder.ts b/libs/shinkai-node-state/src/forms/vector-fs/folder.ts index f7730165d..2a4f9487a 100644 --- a/libs/shinkai-node-state/src/forms/vector-fs/folder.ts +++ b/libs/shinkai-node-state/src/forms/vector-fs/folder.ts @@ -26,3 +26,9 @@ export const saveWebpageToVectorFsFormSchema = z.object({ export type SaveWebpageToVectorFsFormSchema = z.infer< typeof saveWebpageToVectorFsFormSchema >; + +export const createTextFileFormSchema = z.object({ + name: z.string().min(1, 'File name is required'), +}); + +export type CreateTextFileFormSchema = z.infer; From fe91496aef4c36d26dced6b290855cecc483ad06 Mon Sep 17 00:00:00 2001 From: paulclindo Date: Fri, 3 Jan 2025 19:00:02 -0500 Subject: [PATCH 33/39] feat: create/edit text file --- .../vector-fs/components/all-files-tab.tsx | 6 +- .../vector-fs/components/vector-fs-drawer.tsx | 4 + .../components/vector-fs-general-options.tsx | 76 ++++++++++++++----- .../components/vector-fs-item-options.tsx | 45 ++++++++++- .../vector-fs/components/vector-fs-item.tsx | 9 ++- libs/shinkai-i18n/locales/en-US.json | 6 +- libs/shinkai-i18n/locales/es-ES.json | 8 +- libs/shinkai-i18n/locales/id-ID.json | 6 +- libs/shinkai-i18n/locales/ja-JP.json | 6 +- libs/shinkai-i18n/locales/tr-TR.json | 6 +- libs/shinkai-i18n/locales/zh-CN.json | 6 +- libs/shinkai-i18n/src/lib/default/index.ts | 2 + 12 files changed, 147 insertions(+), 33 deletions(-) diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/all-files-tab.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/all-files-tab.tsx index fd89f4d83..6d023c979 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/all-files-tab.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/all-files-tab.tsx @@ -97,9 +97,9 @@ const AllFiles = () => { path: currentGlobalPath, }, { - // select: (data: FileInfo[]) => { - // return data?.sort((a, b) => a.name.localeCompare(b.name)); - // }, + select: (data) => { + return data?.sort((a, b) => a.name.localeCompare(b.name)); + }, refetchInterval: 6000, }, ); diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-drawer.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-drawer.tsx index a9bbc98e8..ac57ce4f7 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-drawer.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-drawer.tsx @@ -17,6 +17,7 @@ import { VectorFileDetails } from './vector-fs-item-detail'; import { VectorFsItemCopyAction, VectorFsItemDeleteAction, + VectorFsItemEditTextFileAction, VectorFsItemMoveAction, } from './vector-fs-item-options'; @@ -70,6 +71,7 @@ export enum VectorFsFolderAction { export enum VectorFsItemAction { Move = 'move-item', Copy = 'copy-item', + Edit = 'edit-item', // txt files Delete = 'delete-item', } @@ -109,6 +111,8 @@ const VectorFSDrawerContent = ({ return ; case VectorFsItemAction.Copy: return ; + case VectorFsItemAction.Edit: + return ; case VectorFsItemAction.Delete: return ; diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-general-options.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-general-options.tsx index 7ca3fb90a..7101b6b14 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-general-options.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-general-options.tsx @@ -11,6 +11,7 @@ import { uploadVRFilesFormSchema, } from '@shinkai_network/shinkai-node-state/forms/vector-fs/folder'; import { useCreateFolder } from '@shinkai_network/shinkai-node-state/v2/mutations/createFolder/useCreateFolder'; +import { useRemoveFsItem } from '@shinkai_network/shinkai-node-state/v2/mutations/removeFsItem/useRemoveFsItem'; import { useUploadVRFiles } from '@shinkai_network/shinkai-node-state/v2/mutations/uploadVRFiles/useUploadVRFiles'; import { Button, @@ -357,8 +358,13 @@ export const SaveWebpageToVectorFsAction = () => { ); }; -// create a new text file -export const CreateTextFileAction = () => { +export const CreateTextFileAction = ({ + initialValues, + mode = 'create', +}: { + initialValues?: { name: string; content: string; path: string }; + mode?: 'create' | 'edit'; +}) => { const { t } = useTranslation(); const auth = useAuth((state) => state.auth); const currentGlobalPath = useVectorFsStore( @@ -370,8 +376,15 @@ export const CreateTextFileAction = () => { const closeDrawerMenu = useVectorFsStore((state) => state.closeDrawerMenu); const createTextFileForm = useForm({ resolver: zodResolver(createTextFileFormSchema), + defaultValues: initialValues, }); + useEffect(() => { + if (initialValues) { + createTextFileForm.setValue('name', initialValues.name); + } + }, [initialValues, createTextFileForm]); + const { isPending, mutateAsync: uploadVRFiles } = useUploadVRFiles({ onSuccess: (_) => { createTextFileForm.reset(); @@ -384,25 +397,48 @@ export const CreateTextFileAction = () => { }, }); + const { mutateAsync: deleteVrItem, isPending: isRemovingItem } = + useRemoveFsItem({ + onError: () => { + toast.error(t('vectorFs.errors.fileDeleted')); + }, + }); + const onSubmit = async (values: CreateTextFileFormSchema) => { if (!auth) return; - closeDrawerMenu(); const textFileContent = textFileContentRef.current?.value; if (!textFileContent) { toast.error('Please enter file content'); return; } - const textFile = new File([textFileContent], `${values.name}.txt`, { type: 'text/plain', }); - await uploadVRFiles({ - nodeAddress: auth?.node_address ?? '', - destinationPath: currentGlobalPath, - files: [textFile], - token: auth?.api_v2_key ?? '', - }); + if (mode === 'create') { + await uploadVRFiles({ + nodeAddress: auth?.node_address ?? '', + destinationPath: currentGlobalPath, + files: [textFile], + token: auth?.api_v2_key ?? '', + }); + } + + if (mode === 'edit') { + await deleteVrItem({ + nodeAddress: auth?.node_address ?? '', + token: auth?.api_v2_key ?? '', + itemPath: initialValues?.path ?? '', + }); + await uploadVRFiles({ + nodeAddress: auth?.node_address ?? '', + destinationPath: currentGlobalPath, + files: [textFile], + token: auth?.api_v2_key ?? '', + }); + } + + closeDrawerMenu(); }; return ( @@ -410,12 +446,13 @@ export const CreateTextFileAction = () => { - {t('vectorFs.actions.createTextFile')} + {mode === 'create' && t('vectorFs.actions.createTextFile')} + {mode === 'edit' && t('vectorFs.actions.editTextFile')}
{ /> )} /> -
-

Content

+
+

Content

diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item-options.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item-options.tsx index 682a846a8..ec4b117be 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item-options.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item-options.tsx @@ -2,13 +2,14 @@ import { useTranslation } from '@shinkai_network/shinkai-i18n'; import { useCopyFsItem } from '@shinkai_network/shinkai-node-state/v2/mutations/copyFsItem/useCopyFsItem'; import { useMoveFsItem } from '@shinkai_network/shinkai-node-state/v2/mutations/moveFsItem/useMoveFsItem'; import { useRemoveFsItem } from '@shinkai_network/shinkai-node-state/v2/mutations/removeFsItem/useRemoveFsItem'; +import { useGetDownloadFile } from '@shinkai_network/shinkai-node-state/v2/queries/getDownloadFile/useGetDownloadFile'; import { Button, DrawerFooter, SheetHeader, SheetTitle, } from '@shinkai_network/shinkai-ui'; -import React from 'react'; +import React, { useEffect } from 'react'; import { toast } from 'sonner'; import { useAuth } from '../../../store/auth'; @@ -17,6 +18,7 @@ import { FolderSelectionList, useVectorFolderSelectionStore, } from './folder-selection-list'; +import { CreateTextFileAction } from './vector-fs-general-options'; export const VectorFsItemMoveAction = () => { const { t } = useTranslation(); @@ -183,3 +185,44 @@ export const VectorFsItemCopyAction = () => { ); }; + +export const VectorFsItemEditTextFileAction = () => { + const auth = useAuth((state) => state.auth); + const selectedFile = useVectorFsStore((state) => state.selectedFile); + + const fileNameWithoutExtension = selectedFile?.name?.split('.')?.[0] ?? ''; + + const [initialValues, setInitialValues] = React.useState({ + name: fileNameWithoutExtension, + path: selectedFile?.path ?? '', + content: '', + }); + + const { mutateAsync: downloadFile } = useGetDownloadFile({}); + + useEffect(() => { + const fetchFileContent = async () => { + if (selectedFile && auth) { + try { + const fileContentBase64 = await downloadFile({ + nodeAddress: auth.node_address, + token: auth.api_v2_key, + path: selectedFile.path, + }); + const fileContent = atob(fileContentBase64); + setInitialValues({ + name: fileNameWithoutExtension, + path: selectedFile.path, + content: fileContent, + }); + } catch (error) { + console.error('Error downloading file content:', error); + } + } + }; + + fetchFileContent(); + }, [selectedFile, auth, downloadFile]); + + return ; +}; diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx index 5b6f9b9e1..c7c62fbb8 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx @@ -26,7 +26,7 @@ import { } from '@shinkai_network/shinkai-ui/helpers'; import { cn } from '@shinkai_network/shinkai-ui/utils'; import { partial } from 'filesize'; -import { CopyIcon, FileInputIcon, TrashIcon } from 'lucide-react'; +import { CopyIcon, Edit2Icon, FileInputIcon, TrashIcon } from 'lucide-react'; import React from 'react'; import { useNavigate } from 'react-router-dom'; @@ -196,6 +196,13 @@ const VectorFsItem = ({ className="w-[160px] border bg-gray-500 px-2.5 py-2" > {[ + { + name: t('vectorFs.actions.edit'), + icon: , + onClick: () => { + setActiveDrawerMenuOption(VectorFsItemAction.Edit); + }, + }, { name: t('vectorFs.actions.move'), icon: , diff --git a/libs/shinkai-i18n/locales/en-US.json b/libs/shinkai-i18n/locales/en-US.json index 7b788b241..13294ac72 100644 --- a/libs/shinkai-i18n/locales/en-US.json +++ b/libs/shinkai-i18n/locales/en-US.json @@ -121,8 +121,11 @@ "addNew": "Add New", "createFolder": "Add New Folder", "uploadFile": "File Upload", + "createTextFile": "Create Text File", + "editTextFile": "Edit Text File", "share": "Share", "unshare": "Unshare", + "edit": "Edit", "move": "Move", "copy": "Copy", "delete": "Delete", @@ -133,7 +136,8 @@ }, "forms": { "folderName": "Folder Name", - "folderDescription": "Folder Description" + "folderDescription": "Folder Description", + "textFileName": "Title" }, "pending": { "filesUploading": "Uploading files" diff --git a/libs/shinkai-i18n/locales/es-ES.json b/libs/shinkai-i18n/locales/es-ES.json index 05bd73674..2bccd899f 100644 --- a/libs/shinkai-i18n/locales/es-ES.json +++ b/libs/shinkai-i18n/locales/es-ES.json @@ -1,6 +1,4 @@ { - "": { - }, "aiFilesSearch": { "description": "Busca para encontrar contenido en todos los archivos de tus archivos AI fácilmente", "filesSelected": "Seleccionados {{count}} archivos", @@ -526,7 +524,10 @@ "addNew": "Añadir nuevo", "copy": "Copiar", "createFolder": "Añadir nueva carpeta", + "createTextFile": "Crear archivo de texto", "delete": "Eliminar", + "edit": "Editar", + "editTextFile": "Editar archivo de texto", "move": "Mover", "searchWithinFolder": "Buscar dentro de la carpeta", "share": "Compartir", @@ -560,7 +561,8 @@ "filesSelected": "{{count}} seleccionados", "forms": { "folderDescription": "Descripción de la carpeta", - "folderName": "Nombre de la carpeta" + "folderName": "Nombre de la carpeta", + "textFileName": "Título" }, "home": "Inicio", "label": "Mi Explorador de Archivos de IA", diff --git a/libs/shinkai-i18n/locales/id-ID.json b/libs/shinkai-i18n/locales/id-ID.json index d33a6fd0a..c3d96f2b6 100644 --- a/libs/shinkai-i18n/locales/id-ID.json +++ b/libs/shinkai-i18n/locales/id-ID.json @@ -524,7 +524,10 @@ "addNew": "Tambah Baru", "copy": "Salin", "createFolder": "Tambah Folder Baru", + "createTextFile": "Buat Berkas Teks", "delete": "Hapus", + "edit": "Edit", + "editTextFile": "Edit Berkas Teks", "move": "Pindah", "searchWithinFolder": "Cari dalam folder", "share": "Bagikan", @@ -558,7 +561,8 @@ "filesSelected": "{{count}} dipilih", "forms": { "folderDescription": "Deskripsi Folder", - "folderName": "Nama Folder" + "folderName": "Nama Folder", + "textFileName": "Judul" }, "home": "Beranda", "label": "Penjelajah File AI Saya", diff --git a/libs/shinkai-i18n/locales/ja-JP.json b/libs/shinkai-i18n/locales/ja-JP.json index ef210fb29..2dab6343c 100644 --- a/libs/shinkai-i18n/locales/ja-JP.json +++ b/libs/shinkai-i18n/locales/ja-JP.json @@ -524,7 +524,10 @@ "addNew": "新規追加", "copy": "コピー", "createFolder": "新しいフォルダを作成", + "createTextFile": "テキストファイルを作成", "delete": "削除", + "edit": "編集", + "editTextFile": "テキストファイルを編集", "move": "移動", "searchWithinFolder": "フォルダ内を検索", "share": "共有", @@ -558,7 +561,8 @@ "filesSelected": "{{count}} 個選択されました", "forms": { "folderDescription": "フォルダの説明", - "folderName": "フォルダ名" + "folderName": "フォルダ名", + "textFileName": "タイトル" }, "home": "ホーム", "label": "私のAIファイルエクスプローラー", diff --git a/libs/shinkai-i18n/locales/tr-TR.json b/libs/shinkai-i18n/locales/tr-TR.json index 855b44dd8..f6c3c2ce1 100644 --- a/libs/shinkai-i18n/locales/tr-TR.json +++ b/libs/shinkai-i18n/locales/tr-TR.json @@ -524,7 +524,10 @@ "addNew": "Yeni Ekle", "copy": "Kopyala", "createFolder": "Yeni Klasör Oluştur", + "createTextFile": "Metin Dosyası Oluştur", "delete": "Sil", + "edit": "Düzenle", + "editTextFile": "Metin Dosyasını Düzenle", "move": "Taşı", "searchWithinFolder": "Klasör içinde ara", "share": "Paylaş", @@ -558,7 +561,8 @@ "filesSelected": "{{count}} seçildi", "forms": { "folderDescription": "Klasör Açıklaması", - "folderName": "Klasör Adı" + "folderName": "Klasör Adı", + "textFileName": "Başlık" }, "home": "Ana Sayfa", "label": "AI Dosya Gezgini", diff --git a/libs/shinkai-i18n/locales/zh-CN.json b/libs/shinkai-i18n/locales/zh-CN.json index 65b1419b9..0172e4211 100644 --- a/libs/shinkai-i18n/locales/zh-CN.json +++ b/libs/shinkai-i18n/locales/zh-CN.json @@ -524,7 +524,10 @@ "addNew": "添加新文件", "copy": "复制", "createFolder": "添加新文件夹", + "createTextFile": "创建文本文件", "delete": "删除", + "edit": "编辑", + "editTextFile": "编辑文本文件", "move": "移动", "searchWithinFolder": "文件夹内搜索", "share": "分享", @@ -558,7 +561,8 @@ "filesSelected": "{{count}} 已选择", "forms": { "folderDescription": "文件夹描述", - "folderName": "文件夹名称" + "folderName": "文件夹名称", + "textFileName": "标题" }, "home": "主页", "label": "我的AI文件资源管理器", diff --git a/libs/shinkai-i18n/src/lib/default/index.ts b/libs/shinkai-i18n/src/lib/default/index.ts index 97183fff3..ca3dde37c 100644 --- a/libs/shinkai-i18n/src/lib/default/index.ts +++ b/libs/shinkai-i18n/src/lib/default/index.ts @@ -142,8 +142,10 @@ export default { createFolder: 'Add New Folder', uploadFile: 'File Upload', createTextFile: 'Create Text File', + editTextFile: 'Edit Text File', share: 'Share', unshare: 'Unshare', + edit: 'Edit', move: 'Move', copy: 'Copy', delete: 'Delete', From 6adba22650d4d3bf82a011a82c0cd17282911531 Mon Sep 17 00:00:00 2001 From: paulclindo Date: Fri, 3 Jan 2025 19:12:59 -0500 Subject: [PATCH 34/39] fixes --- .../vector-fs/components/vector-fs-drawer.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-drawer.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-drawer.tsx index ac57ce4f7..709293d6c 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-drawer.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-drawer.tsx @@ -1,4 +1,5 @@ import { Sheet, SheetContent } from '@shinkai_network/shinkai-ui'; +import { cn } from '@shinkai_network/shinkai-ui/utils'; import { useVectorFsStore } from '../context/vector-fs-context'; import { VectorFolderSelectionProvider } from './folder-selection-list'; @@ -32,6 +33,7 @@ const VectorFSDrawer = () => { (state) => state.setSelectedFolder, ); const setSelectedFile = useVectorFsStore((state) => state.setSelectedFile); + console.log('activeDrawerMenuOption', activeDrawerMenuOption); return ( { @@ -43,7 +45,13 @@ const VectorFSDrawer = () => { }} open={!!activeDrawerMenuOption} > - + From 30583d9738b61607e8bf7a6b0dd54cf89949d375 Mon Sep 17 00:00:00 2001 From: paulclindo Date: Fri, 3 Jan 2025 19:17:27 -0500 Subject: [PATCH 35/39] fix types --- libs/shinkai-message-ts/src/api/jobs/types.ts | 2 +- .../src/v2/mutations/createRecurringTask/index.ts | 1 + .../shinkai-node-state/src/v2/mutations/createToolCode/index.ts | 1 + .../src/v2/mutations/updateRecurringTask/index.ts | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/shinkai-message-ts/src/api/jobs/types.ts b/libs/shinkai-message-ts/src/api/jobs/types.ts index 884645f34..fa0ef685c 100644 --- a/libs/shinkai-message-ts/src/api/jobs/types.ts +++ b/libs/shinkai-message-ts/src/api/jobs/types.ts @@ -60,7 +60,7 @@ export type JobMessage = { job_id: string; callback?: null; content: string; - parent?: string; + parent: string | null; sheet_job_data?: null; tool_key?: string; metadata?: { diff --git a/libs/shinkai-node-state/src/v2/mutations/createRecurringTask/index.ts b/libs/shinkai-node-state/src/v2/mutations/createRecurringTask/index.ts index b7fa82284..35d372081 100644 --- a/libs/shinkai-node-state/src/v2/mutations/createRecurringTask/index.ts +++ b/libs/shinkai-node-state/src/v2/mutations/createRecurringTask/index.ts @@ -47,6 +47,7 @@ export const createRecurringTask = async ({ job_id: jobId, content: message, tool_key: toolKey, + parent: null, }, }, diff --git a/libs/shinkai-node-state/src/v2/mutations/createToolCode/index.ts b/libs/shinkai-node-state/src/v2/mutations/createToolCode/index.ts index 7c7556f89..17fe2ffb4 100644 --- a/libs/shinkai-node-state/src/v2/mutations/createToolCode/index.ts +++ b/libs/shinkai-node-state/src/v2/mutations/createToolCode/index.ts @@ -51,6 +51,7 @@ export const createToolCode = async ({ message: { job_id: currentJobId, content: message, + parent: null, }, tools, language, diff --git a/libs/shinkai-node-state/src/v2/mutations/updateRecurringTask/index.ts b/libs/shinkai-node-state/src/v2/mutations/updateRecurringTask/index.ts index b16a9d146..5f75563dc 100644 --- a/libs/shinkai-node-state/src/v2/mutations/updateRecurringTask/index.ts +++ b/libs/shinkai-node-state/src/v2/mutations/updateRecurringTask/index.ts @@ -38,6 +38,7 @@ export const updateRecurringTask = async ({ job_id: jobId, content: message, tool_key: toolKey, + parent: null, }, }, }, From 97db49669262a125ac11f7832c1dde22db9c2af3 Mon Sep 17 00:00:00 2001 From: paulclindo Date: Fri, 3 Jan 2025 21:11:06 -0500 Subject: [PATCH 36/39] fix --- .../vector-fs/components/vector-fs-item.tsx | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx index c7c62fbb8..9e885e07a 100644 --- a/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx +++ b/apps/shinkai-desktop/src/components/vector-fs/components/vector-fs-item.tsx @@ -196,7 +196,7 @@ const VectorFsItem = ({ className="w-[160px] border bg-gray-500 px-2.5 py-2" > {[ - { + file.path.includes('.txt') && { name: t('vectorFs.actions.edit'), icon: , onClick: () => { @@ -224,22 +224,24 @@ const VectorFsItem = ({ setActiveDrawerMenuOption(VectorFsItemAction.Delete); }, }, - ].map((option, idx) => ( - - {idx === 2 && } - { - event.stopPropagation(); - option.onClick(); - setSelectedFile(file); - }} - > - {option.icon} - {option.name} - - - ))} + ] + .filter((item) => !!item) + .map((option, idx) => ( + + {idx === 2 && } + { + event.stopPropagation(); + option.onClick(); + setSelectedFile(file); + }} + > + {option.icon} + {option.name} + + + ))} From 9f83e2329a0040b143cdb9ecca46770702014e4e Mon Sep 17 00:00:00 2001 From: Nico Arqueros Date: Fri, 3 Jan 2025 20:32:33 -0600 Subject: [PATCH 37/39] ignroe visor --- .github/workflows/release-dev.yml | 100 ++++++++--------- .github/workflows/release-prod.yml | 170 ++++++++++++++--------------- 2 files changed, 135 insertions(+), 135 deletions(-) diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index e89b3bd72..eee073a70 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -25,56 +25,56 @@ jobs: id: package-version uses: Saionaro/extract-package-version@v1.2.1 - release-shinkai-visor: - needs: prebuild - runs-on: ubuntu-latest - environment: development - steps: - - name: Check out repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup Node version - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - check-latest: false - cache: "npm" - cache-dependency-path: package-lock.json - - - name: Install dependencies - run: | - npm cache verify - npm ci --no-audit --prefer-offline - - - name: Run NX build on shinkai-visor - run: npx nx build shinkai-visor --skip-nx-cache - env: - VERSION: ${{ needs.prebuild.outputs.version }}.${{github.run_number}} - NAME_PREFIX: '[Dev]' - DESCRIPTION_PREFIX: '[Dev]' - - - name: Zip extension - run: cd ./dist/apps && zip -r shinkai-visor.zip shinkai-visor - - - name: Upload & Release - uses: mnao305/chrome-extension-upload@v4.0.1 - continue-on-error: true - with: - file-path: dist/apps/shinkai-visor.zip - extension-id: ${{ secrets.CHROME_EXTENSION_ID }} - client-id: ${{ secrets.CHROME_CLIENT_ID }} - client-secret: ${{ secrets.CHROME_CLIENT_SECRET }} - refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }} - publish: false - - - uses: actions/upload-artifact@v3 - with: - name: shinkai-visor - path: dist/apps/shinkai-visor - if-no-files-found: error - retention-days: 5 + # release-shinkai-visor: + # needs: prebuild + # runs-on: ubuntu-latest + # environment: development + # steps: + # - name: Check out repository + # uses: actions/checkout@v4 + # with: + # fetch-depth: 0 + + # - name: Setup Node version + # uses: actions/setup-node@v4 + # with: + # node-version-file: '.nvmrc' + # check-latest: false + # cache: "npm" + # cache-dependency-path: package-lock.json + + # - name: Install dependencies + # run: | + # npm cache verify + # npm ci --no-audit --prefer-offline + + # - name: Run NX build on shinkai-visor + # run: npx nx build shinkai-visor --skip-nx-cache + # env: + # VERSION: ${{ needs.prebuild.outputs.version }}.${{github.run_number}} + # NAME_PREFIX: '[Dev]' + # DESCRIPTION_PREFIX: '[Dev]' + + # - name: Zip extension + # run: cd ./dist/apps && zip -r shinkai-visor.zip shinkai-visor + + # - name: Upload & Release + # uses: mnao305/chrome-extension-upload@v4.0.1 + # continue-on-error: true + # with: + # file-path: dist/apps/shinkai-visor.zip + # extension-id: ${{ secrets.CHROME_EXTENSION_ID }} + # client-id: ${{ secrets.CHROME_CLIENT_ID }} + # client-secret: ${{ secrets.CHROME_CLIENT_SECRET }} + # refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }} + # publish: false + + # - uses: actions/upload-artifact@v3 + # with: + # name: shinkai-visor + # path: dist/apps/shinkai-visor + # if-no-files-found: error + # retention-days: 5 release-shinkai-desktop: needs: prebuild diff --git a/.github/workflows/release-prod.yml b/.github/workflows/release-prod.yml index 445e34f02..1c49e46a1 100644 --- a/.github/workflows/release-prod.yml +++ b/.github/workflows/release-prod.yml @@ -31,49 +31,49 @@ jobs: script: | core.setFailed('Version mismatch') - release-shinkai-visor: - needs: prebuild - runs-on: ubuntu-latest - environment: production - steps: - - name: Check out repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup Node version - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - check-latest: false - cache: "npm" - cache-dependency-path: package-lock.json - - - name: Install dependencies - run: | - npm cache verify - npm ci --no-audit --prefer-offline - - - name: Run NX build on shinkai-visor - run: npx nx build shinkai-visor --skip-nx-cache - env: - VERSION: ${{ needs.prebuild.outputs.version }}.${{github.run_number}} - NAME_PREFIX: '' - DESCRIPTION_PREFIX: '' - PUBLIC_KEY: ${{ secrets.CHROME_EXTENSION_PUBLIC_KEY }} - - - name: Zip extension - run: cd ./dist/apps && zip -r shinkai-visor.zip shinkai-visor - - - name: Upload & Release - uses: mnao305/chrome-extension-upload@v4.0.1 - with: - file-path: dist/apps/shinkai-visor.zip - extension-id: ${{ secrets.CHROME_EXTENSION_ID }} - client-id: ${{ secrets.CHROME_CLIENT_ID }} - client-secret: ${{ secrets.CHROME_CLIENT_SECRET }} - refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }} - publish: false + # release-shinkai-visor: + # needs: prebuild + # runs-on: ubuntu-latest + # environment: production + # steps: + # - name: Check out repository + # uses: actions/checkout@v4 + # with: + # fetch-depth: 0 + + # - name: Setup Node version + # uses: actions/setup-node@v4 + # with: + # node-version-file: '.nvmrc' + # check-latest: false + # cache: "npm" + # cache-dependency-path: package-lock.json + + # - name: Install dependencies + # run: | + # npm cache verify + # npm ci --no-audit --prefer-offline + + # - name: Run NX build on shinkai-visor + # run: npx nx build shinkai-visor --skip-nx-cache + # env: + # VERSION: ${{ needs.prebuild.outputs.version }}.${{github.run_number}} + # NAME_PREFIX: '' + # DESCRIPTION_PREFIX: '' + # PUBLIC_KEY: ${{ secrets.CHROME_EXTENSION_PUBLIC_KEY }} + + # - name: Zip extension + # run: cd ./dist/apps && zip -r shinkai-visor.zip shinkai-visor + + # - name: Upload & Release + # uses: mnao305/chrome-extension-upload@v4.0.1 + # with: + # file-path: dist/apps/shinkai-visor.zip + # extension-id: ${{ secrets.CHROME_EXTENSION_ID }} + # client-id: ${{ secrets.CHROME_CLIENT_ID }} + # client-secret: ${{ secrets.CHROME_CLIENT_SECRET }} + # refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }} + # publish: false release-shinkai-desktop: needs: prebuild @@ -380,45 +380,45 @@ jobs: } ] } - - name: Post Shinkai Visor to a Slack channel - uses: slackapi/slack-github-action@v1.26.0 - env: - SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} - with: - channel-id: 'C072VJ6E7GC' - payload: | - { - "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "📦 New build: Shinkai Visor v${{ needs.prebuild.outputs.version }}.${{ github.run_number }}", - "emoji": true - } - }, - { - "type": "divider" - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "Found it at " - } - }, - { - "type": "divider" - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "_💡 Send it for review and publish on to start the rollout_" - } - ] - } - - ] - } + # - name: Post Shinkai Visor to a Slack channel + # uses: slackapi/slack-github-action@v1.26.0 + # env: + # SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + # with: + # channel-id: 'C072VJ6E7GC' + # payload: | + # { + # "blocks": [ + # { + # "type": "header", + # "text": { + # "type": "plain_text", + # "text": "📦 New build: Shinkai Visor v${{ needs.prebuild.outputs.version }}.${{ github.run_number }}", + # "emoji": true + # } + # }, + # { + # "type": "divider" + # }, + # { + # "type": "section", + # "text": { + # "type": "mrkdwn", + # "text": "Found it at " + # } + # }, + # { + # "type": "divider" + # }, + # { + # "type": "context", + # "elements": [ + # { + # "type": "mrkdwn", + # "text": "_💡 Send it for review and publish on to start the rollout_" + # } + # ] + # } + + # ] + # } From 9c19f6477764b41e73a6a4a024c14c20bc0062c4 Mon Sep 17 00:00:00 2001 From: Nico Arqueros Date: Fri, 3 Jan 2025 20:36:57 -0600 Subject: [PATCH 38/39] skip build --- apps/shinkai-visor/project.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/shinkai-visor/project.json b/apps/shinkai-visor/project.json index a9acc9c7c..0aff4626c 100644 --- a/apps/shinkai-visor/project.json +++ b/apps/shinkai-visor/project.json @@ -21,7 +21,8 @@ }, "production": { "mode": "production", - "force": true + "force": true, + "buildable": false } } }, From ae07375055ee5b8440effdf42097d35616bd2770 Mon Sep 17 00:00:00 2001 From: Nico Arqueros Date: Fri, 3 Jan 2025 20:45:06 -0600 Subject: [PATCH 39/39] another try --- .github/workflows/pr-ci-healchecks.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-ci-healchecks.yml b/.github/workflows/pr-ci-healchecks.yml index 1af9d6d2d..1e6aecdca 100644 --- a/.github/workflows/pr-ci-healchecks.yml +++ b/.github/workflows/pr-ci-healchecks.yml @@ -51,7 +51,8 @@ jobs: env: OPEN_AI_API_KEY: ${{ secrets.OPEN_AI_API_KEY }} run: | - npx nx run-many -t lint,build,test --parallel=3 --skip-nx-cache --verbose --exclude=shinkai-desktop + npx nx run-many -t lint,test --parallel=3 --skip-nx-cache --verbose --exclude=shinkai-desktop,shinkai-visor + npx nx run-many -t build --parallel=3 --skip-nx-cache --verbose --exclude=shinkai-desktop,shinkai-visor npx nx lint shinkai-desktop # - name: Run E2E for Visor