Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
new layout
Vasek Mlejnsky0b8df7f33804
diff --git a/components/AgentLogFileContent.tsx b/components/AgentLogFileContent.tsxnew file mode 100644index 000000000..f81c094b8--- /dev/null+++ b/components/AgentLogFileContent.tsx@@ -0,0 +1,67 @@+import {+ useState,+} from 'react'+import { useRouter } from 'next/router'++import { log_files } from 'db/prisma'+import {+ SystemPromptLog,+ UserPromptLog,+ AssistantPromptLog,+ AgentPromptLogs,+ AgentNextActionLog,+} from 'utils/agentLogs'+import AgentPrompLogDetail from 'components/AgentPromptLogDetail'+import AgentPromptLogsList from 'components/AgentPromptLogsList'+import AgentNextActionLogDetail from 'components/AgentNextActionLogDetail'++export interface Props {+ logFile?: Omit<log_files, 'content'> & { content: AgentPromptLogs | AgentNextActionLog }+}++function AgentLogFileContent({+ logFile,+}: Props) {+ const router = useRouter()+ const [selectedLog, setSelectedLog] = useState<SystemPromptLog | UserPromptLog | AssistantPromptLog>()++ // return (+ // <>+ // <AgentPromptLogsList+ // logs={!!logFile ? (logFile.content as AgentPromptLogs)?.logs : []}+ // onSelected={setSelectedLog}+ // />+ // <AgentPrompLogDetail+ // log={selectedLog}+ // />+ // </>+ // )++ if (!logFile) return null++ return (+ <div className="flex space-x-2 items-start justify-start max-w-full">+ {logFile.filename.includes('full_message_history') || logFile.filename.includes('current_context') ? (+ <>+ <AgentPromptLogsList+ logs={(logFile.content as AgentPromptLogs).logs}+ onSelected={setSelectedLog}+ />+ <AgentPrompLogDetail+ log={selectedLog}+ />+ </>+ ) : logFile.filename.includes('next_action') ? (+ <AgentNextActionLogDetail+ log={logFile.content as AgentNextActionLog}+ />+ ) : (+ <div>+ Unexpected JSON format. Please reach out to the e2b team.+ </div>+ )}+ </div>+ )+}++export default AgentLogFileContent\ No newline at end of filediff --git a/components/AgentLogFilesList.tsx b/components/AgentLogFilesList.tsxindex 37cf3bdac..8acb04951 100644--- a/components/AgentLogFilesList.tsx+++ b/components/AgentLogFilesList.tsx@@ -8,12 +8,19 @@ import {import Link from 'next/link'import clsx from 'clsx'import { useRouter } from 'next/router'+import Splitter from '@devbookhq/splitter'-import { log_files } from '@prisma/client'+import { log_files } from 'db/prisma'import { useUploadLogs } from 'hooks/useUploadLogs'import LogFolderUploadButton from 'components/LogFolderUploadButton'-import { LiteLogUpload } from 'utils/agentLogs'+import {+ LiteLogUpload,+ AgentPromptLogs,+ AgentNextActionLog,+} from 'utils/agentLogs'import Spinner from 'components/Spinner'+import AgentLogFileContent from 'components/AgentLogFileContent'+import { useGetLogFile } from 'hooks/useGetLogFile'export interface Props {logUploads: LiteLogUpload[]@@ -24,8 +31,10 @@ function AgentLogFilesList({logUploads,defaultProjectID,}: Props) {+ const getLogFile = useGetLogFile()const [isUploading, setIsUploading] = useState(false)const [openedLogUploads, setOpeneLogUploads] = useState<string[]>([])+ const [selectedLogFile, setSelectedLogFile] = useState<Omit<log_files, 'content'> & { content: AgentPromptLogs | AgentNextActionLog }>()const router = useRouter()const fileInput = useRef<HTMLInputElement>(null)const uploadFiles = useUploadLogs(defaultProjectID)@@ -96,6 +105,49 @@ function AgentLogFilesList({}}+ function logFileURL(logFileID: string) {+ // Create URL like so /?logFileID=123 and also pass any existing queries in the router.+ const query = {+ ...router.query,+ logFileID,+ selectedLog: '0',+ }+ return `/?${new URLSearchParams(query).toString()}`+ }++ async function selectLogFile(logFileID: string) {+ // Log files in logUploads don't have content. We fetch the full log file lazily.+ const logFile = await getLogFile(logFileID)+ if (!logFile) return++ const parsedFileContent = JSON.parse(logFile.content)++ // Specific to AutoGPT+ if (logFile.filename.includes('next_action')) {+ setSelectedLogFile({+ ...logFile,+ content: parsedFileContent,+ })+ } else if (logFile.filename.includes('full_message_history') || logFile.filename.includes('current_context')) {+ setSelectedLogFile({+ ...logFile,+ content: {+ //logs: parsedFileContent as AgentNextActionLog,+ logs: parsedFileContent as any,+ },+ })+ } else {+ setSelectedLogFile({+ ...logFile,+ content: {+ ...parsedFileContent,+ logs: parsedFileContent?.context || [],+ context: undefined,+ },+ })+ }+ }+return (<main className="overflow-hidden flex flex-col max-h-full flex-1"><input@@ -129,79 +181,95 @@ function AgentLogFilesList({)}{sortedLogUploads.length > 0 && (- <div className="flex flex-col space-y-4 p-4 sm:p-6 lg:px-8 overflow-auto">- {sortedLogUploads.map((logUpload, i) => (- <div- key={logUpload.id}- >+ <Splitter+ gutterClassName={clsx(+ 'bg-gray-900 hover:bg-[#6366F1] transition-all delay-75 duration-[400ms] px-0.5 rounded-sm group',+ )}+ draggerClassName={clsx(+ 'bg-gray-700 group-hover:bg-[#6366F1] transition-all delay-75 duration-[400ms] w-0.5 h-full',+ )}+ classes={['flex pr-2 overflow-auto', 'bg-gray-900 flex pl-2']}+ >+ <div className="flex flex-col space-y-4 p-4 sm:p-6 lg:px-8 overflow-auto min-w-[320px]">+ {sortedLogUploads.map((logUpload, i) => (<div- className="flex flex-col space-y-2"+ key={logUpload.id}>- <div className="flex items-center space-x-2">- <div- className={clsx(- 'p-1 cursor-pointer hover:bg-gray-700 transition-all rounded-md',- openedLogUploads.includes(logUpload.id) && 'bg-gray-700',- !openedLogUploads.includes(logUpload.id) && 'bg-gray-800',- )}- onClick={() => toggleLogUpload(logUpload.id)}- >- <ChevronRight size={15} className={clsx(- 'text-gray-400',- 'transition-all',- 'select-none',- openedLogUploads.includes(logUpload.id) && 'rotate-90',- )} />+ <div+ className="flex flex-col space-y-2"+ >+ <div className="flex items-center space-x-2">+ <div+ className={clsx(+ 'p-1 cursor-pointer hover:bg-gray-700 transition-all rounded-md',+ openedLogUploads.includes(logUpload.id) && 'bg-gray-700',+ !openedLogUploads.includes(logUpload.id) && 'bg-gray-800',+ )}+ onClick={() => toggleLogUpload(logUpload.id)}+ >+ <ChevronRight size={15} className={clsx(+ 'text-gray-400',+ 'transition-all',+ 'select-none',+ openedLogUploads.includes(logUpload.id) && 'rotate-90',+ )} />+ </div>+ <span+ className={clsx(+ 'text-sm',+ 'font-semibold',+ 'text-gray-500',+ 'whitespace-nowrap',+ )}+ // This prevents hydration warning for timestamps rendered via SSR+ suppressHydrationWarning+ >+ Uploaded {logUpload.created_at.toLocaleString()}+ </span></div>- <span- className={clsx(- 'text-sm',- 'font-semibold',- 'text-gray-500',- )}- // This prevents hydration warning for timestamps rendered via SSR- suppressHydrationWarning- >- Uploaded at {logUpload.created_at.toLocaleString()}- </span>- </div>- {openedLogUploads.includes(logUpload.id) && (- <div className="flex flex-col space-y-3 border-l border-gray-800 pl-2 ml-[10px]">- {logUpload.log_files.map((logFile) => (- <span- key={logFile.id}- className={clsx(- 'rounded-md',- 'py-0.5',- 'px-2',- 'text-gray-200',- 'hover:bg-[#1F2437]',- 'transition-all',- 'w-full',- 'text-sm',- 'cursor-pointer',- 'font-mono',- 'flex',- 'items-center',- 'space-x-2',- )}- >- <Link- href={`/log/${logFile.id}`}+ {openedLogUploads.includes(logUpload.id) && (+ <div className="flex flex-col space-y-3 border-l border-gray-800 pl-2 ml-[10px]">+ {logUpload.log_files.map((logFile) => (+ <span+ key={logFile.id}+ className={clsx(+ 'rounded-md',+ 'py-0.5',+ 'px-2',+ 'text-gray-200',+ 'hover:bg-[#1F2437]',+ 'transition-all',+ 'w-full',+ 'text-sm',+ 'cursor-pointer',+ 'font-mono',+ 'flex',+ 'items-center',+ 'space-x-2',+ )}>- {logFile.relativePath.split('/').map(p => (- <span key={p}>{'/ '}{p}</span>- ))}- </Link>- </span>- ))}- </div>- )}+ <Link+ href={logFileURL(logFile.id)}+ shallow={true}+ onClick={() => selectLogFile(logFile.id)}+ >+ {logFile.relativePath.split('/').map(p => (+ <span key={p}>{'/ '}{p}</span>+ ))}+ </Link>+ </span>+ ))}+ </div>+ )}+ </div></div>- </div>- ))}- </div>+ ))}+ </div>+ <AgentLogFileContent+ logFile={selectedLogFile}+ />+ </Splitter>)}</main >)diff --git a/components/AgentPromptLogDetail.tsx b/components/AgentPromptLogDetail.tsxindex 62759022b..c5037386e 100644--- a/components/AgentPromptLogDetail.tsx+++ b/components/AgentPromptLogDetail.tsx@@ -14,7 +14,7 @@ function AgentPrompLogDetail({log,}: Props) {return (- <div className="overflow-auto p-2 h-full bg-[#1F2437] rounded-md flex flex-col space-y-4 w-full border border-gray-800">+ <div className="overflow-auto p-2 h-full bg-[#1F2437] rounded-md flex flex-col space-y-4 border border-gray-800 min-w-[300px]">{log && (<><div className="flex flex-col space-y-1 w-full">diff --git a/components/AgentPromptLogsList.tsx b/components/AgentPromptLogsList.tsxindex 0cd56b4f2..b8c47d116 100644--- a/components/AgentPromptLogsList.tsx+++ b/components/AgentPromptLogsList.tsx@@ -1,8 +1,8 @@import {useState,useEffect,- Fragment,useCallback,+ Fragment,} from 'react'import { useRouter } from 'next/router'import clsx from 'clsx'@@ -28,9 +28,10 @@ function AgentPromptLogsList({setSelectedLogIdx(idx)onSelected(logs[idx])router.replace({- pathname: `/log/${router.query.logFileID}`,+ // pathname: `/log/${router.query.logFileID}`,+ pathname: '',query: {- ...router.query['filename'] && { filename: router.query['filename'] },+ ...router.query,selectedLog: idx.toString(),},}, undefined, { shallow: true })@@ -69,43 +70,38 @@ function AgentPromptLogsList({}, [logs, selectLog, selectedLogIdx])return (- <div className="flex-1 flex flex-col space-y-2 max-w-full w-full overflow-hidden">- <h2 className="font-medium text-sm text-gray-500">Logs</h2>-+ <div className="flex flex-col space-y-1 overflow-auto">{logs.length === 0 && (<div className="flex-1 flex items-center justify-center"><p className="text-gray-400">No logs</p></div>)}-- <div className="flex-1 flex flex-col space-y-1 max-w-full w-full overflow-auto">- {logs.map((ctx, idx) => (- <Fragment key={idx}>- <div className="flex items-center space-x-2">- <span className={clsx(- 'font-bold text-sm capitalize min-w-[72px]',- selectedLogIdx === idx && 'text-[#6366F1]',- selectedLogIdx !== idx && 'text-[#55618C]',- )}- >- {ctx.role}- </span>- <span- className={clsx(- 'text-sm text-gray-100 max-w-full truncate p-2 hover:bg-[#1F2437] transition-all rounded-md cursor-pointer w-full',- selectedLogIdx === idx && 'bg-[#1F2437]',- )}- onClick={() => selectLog(idx)}- >- {ctx.content}- </span>- </div>- {idx !== logs.length - 1 && (- <div className="ml-1 rounded min-h-[20px] w-px bg-gray-800" />+ {logs.map((ctx, idx) => (+ <Fragment key={idx}>+ <div className="flex items-center space-x-2">+ <span className={clsx(+ 'font-bold text-sm capitalize min-w-[72px]',+ selectedLogIdx === idx && 'text-[#6366F1]',+ selectedLogIdx !== idx && 'text-[#55618C]',)}- </Fragment>- ))}- </div>+ >+ {ctx.role}+ </span>+ <span+ className={clsx(+ 'text-sm text-gray-100 max-w-full truncate p-2 hover:bg-[#1F2437] transition-all rounded-md cursor-pointer w-full',+ selectedLogIdx === idx && 'bg-[#1F2437]',+ )}+ onClick={() => selectLog(idx)}+ >+ {ctx.content}+ </span>+ </div>+ {idx !== logs.length - 1 && (+ <div className="ml-1 rounded min-h-[20px] w-px bg-gray-800" />+ )}+ </Fragment>+ ))}</div>)}diff --git a/components/Layout.tsx b/components/Layout.tsxindex 15a0554bb..44c0d076b 100644--- a/components/Layout.tsx+++ b/components/Layout.tsx@@ -106,7 +106,7 @@ function Layout({ children }: PropsWithChildren) {/></div>- <div className="xl:pl-56 flex flex-col flex-1 max-h-full">+ <div className="xl:pl-48 flex flex-col flex-1 max-h-full">{/* Mobile menu icon */}<div className="xl:hidden sticky top-0 z-40 flex justify-between h-16 shrink-0 items-center gap-x-6 border-b border-white/5 bg-gray-900 px-4 shadow-sm sm:px-6 lg:px-8"><button type="button" className="-m-2.5 p-2.5 text-white xl:hidden" onClick={() => setIsSidebarOpen(true)}>diff --git a/components/Sidebar/DashboardDesktopSidebar.tsx b/components/Sidebar/DashboardDesktopSidebar.tsxindex c89c34b92..cfbd4cb7c 100644--- a/components/Sidebar/DashboardDesktopSidebar.tsx+++ b/components/Sidebar/DashboardDesktopSidebar.tsx@@ -19,7 +19,7 @@ function DashboardDesktopSidebar({const isOnLogDetail = router.pathname.startsWith('/log/[logFileID]')return (- <div className="hidden xl:fixed xl:inset-y-0 xl:z-50 xl:flex xl:w-56 xl:flex-col">+ <div className="hidden xl:fixed xl:inset-y-0 xl:z-50 xl:flex xl:w-48 xl:flex-col">{/* Sidebar component, swap this element with another sidebar if you like */}<div className="flex grow flex-col gap-y-5 overflow-y-auto bg-black/10 px-6 border-r border-white/5">{/* Logo */}diff --git a/components/index.html b/components/index.htmlnew file mode 100644index 000000000..af011b4de--- /dev/null+++ b/components/index.html@@ -0,0 +1 @@+<!DOCTYPE html><html><head><style data-next-hide-fouc="true">body{display:none}</style><noscript data-next-hide-fouc="true"><style>body{display:block}</style></noscript><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta content="follow, index" name="robots"/><link href="/favicon.ico" rel="shortcut icon"/><meta content="e2b Dashboard" name="description"/><meta content="website" property="og:type"/><meta content="Dashboard | e2b" property="og:site_name"/><meta content="e2b Dashboard" property="og:description"/><meta content="Dashboard | e2b" property="og:title"/><meta content="summary_large_image" name="twitter:card"/><meta content="@devbookhq" name="twitter:site"/><meta content="Dashboard | e2b" name="twitter:title"/><meta content="e2b Dashboard" name="twitter:description"/><title>404: This page could not be found</title><meta name="next-head-count" content="14"/><link rel="preload" href="/_next/static/media/2aaf0723e720e8b9-s.p.woff2" as="font" type="font/woff2" crossorigin="anonymous" data-next-font="size-adjust"/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills.js?ts=1687104682070"></script><script src="/_next/static/chunks/webpack.js?ts=1687104682070" defer=""></script><script src="/_next/static/chunks/main.js?ts=1687104682070" defer=""></script><script src="/_next/static/chunks/pages/_app.js?ts=1687104682070" defer=""></script><script src="/_next/static/chunks/pages/_error.js?ts=1687104682070" defer=""></script><script src="/_next/static/development/_buildManifest.js?ts=1687104682070" defer=""></script><script src="/_next/static/development/_ssgManifest.js?ts=1687104682070" defer=""></script><noscript id="__next_css__DO_NOT_USE__"></noscript></head><body><div id="__next"><div class="__variable_0ec1f4 font-sans flex h-full w-full flex-1 flex-col overflow-hidden"><div class="overflow-hidden"><div class="hidden xl:fixed xl:inset-y-0 xl:z-50 xl:flex xl:w-48 xl:flex-col"><div class="flex grow flex-col gap-y-5 overflow-y-auto bg-black/10 px-6 border-r border-white/5"><nav class="flex flex-1 flex-col space-y-6 py-[22px]"><div class="font-bold text-gray-100">e2b</div><ul role="list" class="flex flex-1 flex-col gap-y-7"><li><ul role="list" class="-mx-2 space-y-1"><li><a class="text-gray-400 hover:text-white hover:bg-[#1F2437] group gap-x-3 rounded-md px-2 py-1 text-sm leading-6 font-semibold flex items-center" href="/?view=logs"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="shrink-0" aria-hidden="true"><line x1="8" x2="21" y1="6" y2="6"></line><line x1="8" x2="21" y1="12" y2="12"></line><line x1="8" x2="21" y1="18" y2="18"></line><line x1="3" x2="3.01" y1="6" y2="6"></line><line x1="3" x2="3.01" y1="12" y2="12"></line><line x1="3" x2="3.01" y1="18" y2="18"></line></svg>Agent Logs</a></li></ul></li><li class="-mx-6 mt-auto"><div class="flex items-center gap-x-4 px-6 py-3 text-sm font-semibold leading-6 text-white"><button class="text-sm font-semibold text-white">Sign Out</button></div></li></ul></nav></div></div></div><div class="xl:pl-48 flex flex-col flex-1 max-h-full"><div class="xl:hidden sticky top-0 z-40 flex justify-between h-16 shrink-0 items-center gap-x-6 border-b border-white/5 bg-gray-900 px-4 shadow-sm sm:px-6 lg:px-8"><button type="button" class="-m-2.5 p-2.5 text-white xl:hidden"><span class="sr-only">Open sidebar</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-menu" aria-hidden="true"><line x1="4" x2="20" y1="12" y2="12"></line><line x1="4" x2="20" y1="6" y2="6"></line><line x1="4" x2="20" y1="18" y2="18"></line></svg></button><div class="xl:hidden"><div class="flex flex-col items-end flex-1"><div><button class="border-white/5 text-gray-400 group ml-auto flex items-center space-x-1 cursor-pointer py-1 px-2 rounded-md bg-gray-900 border border-white/5 hover:border-white/10 transition-all"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class=""><path d="m3 21 1.9-5.7a8.5 8.5 0 1 1 3.8 3.8z"></path></svg><span class="text-sm">Send feedback to CEO</span></button><div class="relative flex flex-row-reverse pt-1"></div></div></div></div></div><div class="hidden xl:flex py-2 px-6 border-b border-white/5"><div class="flex flex-col items-end flex-1"><div><button class="border-white/5 text-gray-400 group ml-auto flex items-center space-x-1 cursor-pointer py-1 px-2 rounded-md bg-gray-900 border border-white/5 hover:border-white/10 transition-all"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class=""><path d="m3 21 1.9-5.7a8.5 8.5 0 1 1 3.8 3.8z"></path></svg><span class="text-sm">Send feedback to CEO</span></button><div class="relative flex flex-row-reverse pt-1"></div></div></div></div><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block;text-align:left"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found<!-- -->.</h2></div></div></div></div></div></div><script src="/_next/static/chunks/react-refresh.js?ts=1687104682070"></script><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"development","isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>\ No newline at end of filediff --git a/hooks/useGetLogFile.ts b/hooks/useGetLogFile.tsnew file mode 100644index 000000000..7834d7e41--- /dev/null+++ b/hooks/useGetLogFile.ts@@ -0,0 +1,34 @@+// Tries to fetch a log file from the DB based on the log file ID.+import { log_files } from '@prisma/client'+import { useCallback } from 'react'+import useSWRMutation from 'swr/mutation'++export interface GetLogFile {+ id: string+}++export interface GetLogResponse {+ // TODO+}++async function handleGetLog(url: string, { arg }: { arg: GetLogFile }) {+ if (!arg.id) { return }++ const response = await fetch(`${url}/${arg.id}`, {+ method: 'GET',+ headers: {+ 'Content-Type': 'application/json',+ },+ })+ return await response.json() as log_files+}++export function useGetLogFile() {+ const {+ trigger: getLog,+ } = useSWRMutation('/api/log_file', handleGetLog)++ return useCallback(async (logFileID: string) => getLog({+ id: logFileID,+ }), [getLog])+}\ No newline at end of filediff --git a/pages/api/log_file/[:logFileID].ts b/pages/api/log_file/[:logFileID].tsnew file mode 100644index 000000000..43a23e041--- /dev/null+++ b/pages/api/log_file/[:logFileID].ts@@ -0,0 +1,98 @@+import { createServerSupabaseClient } from '@supabase/auth-helpers-nextjs'+import { NextApiRequest, NextApiResponse } from 'next'++import { prisma } from 'db/prisma'+import { serverCreds } from 'db/credentials'++async function getLog(req: NextApiRequest, res: NextApiResponse) {+ let {+ ':logFileID': logFileID,+ } = req.query++ try {+ if (!logFileID) {+ res.status(400).json({ statusCode: 400, message: 'Missing log ID in URL' })+ return+ }+ logFileID = logFileID as string++ const supabase = createServerSupabaseClient({ req, res }, serverCreds)+ const { data: { session } } = await supabase.auth.getSession()+ if (!session) {+ return res.status(401).json({+ error: 'not_authenticated',+ description: 'The user does not have an active session or is not authenticated',+ })+ }++ const user = await prisma.auth_users.findUnique({+ where: {+ id: session.user.id,+ },+ include: {+ users_teams: {+ include: {+ teams: {+ include: {+ projects: {+ include: {+ log_files: {+ where: {+ id: logFileID,+ },+ }+ },+ },+ },+ },+ },+ },+ },+ })++ if (!user) {+ return res.status(401).json({+ error: 'invalid_user',+ })+ }++ const hasAccessToLogs = user+ .users_teams+ .flatMap(t => t.teams.projects)+ .flatMap(p => p.log_files)+ .some(l => l.id === logFileID)++ if (!hasAccessToLogs) {+ return res.status(401).json({+ error: 'logs_does_not_belong_to_user',+ })+ }++ const logFile = await prisma.log_files.findUnique({+ where: {+ id: logFileID,+ },+ })+ res.status(200).json(logFile)+ } catch (err: any) {+ console.error(err)+ res.status(500).json({ statusCode: 500, message: err.message })+ }+}++async function handler(+ req: NextApiRequest,+ res: NextApiResponse,+) {+ console.log('HANDLER')+ if (req.method === 'GET') {+ await getLog(req, res)+ return+ }++ res.setHeader('Allow', ['GET'])+ res.status(405).json({ statusCode: 405, message: 'Method Not Allowed' })+ return+}++export default handlerdiff --git a/pages/api/logs/index.ts b/pages/api/logs/index.tsindex 858784c00..7c07f48b3 100644--- a/pages/api/logs/index.ts+++ b/pages/api/logs/index.ts@@ -5,6 +5,7 @@ import { prisma } from 'db/prisma'import { serverCreds } from 'db/credentials'import { PostLogs } from 'hooks/useUploadLogs'import { DeleteLogs } from 'hooks/useRemoveLogs'+// import { GetLogFile } from 'hooks/useLogFile'async function deleteLogs(req: NextApiRequest, res: NextApiResponse) {const {@@ -172,7 +173,7 @@ async function handler(return}- res.setHeader('Allow', ['POST', 'DELETE'])+ res.setHeader('Allow', ['GET', 'POST', 'DELETE'])res.status(405).json({ statusCode: 405, message: 'Method Not Allowed' })return}diff --git a/pages/log/[logFileID].tsx b/pages/log/[logFileID].tsxindex 55a6383cf..5e97876f0 100644--- a/pages/log/[logFileID].tsx+++ b/pages/log/[logFileID].tsx@@ -1,5 +1,4 @@import { useState } from 'react'-import { AgentPromptLogs, AgentNextActionLog, } from 'utils/agentLogs'import type { GetServerSideProps } from 'next'import { createServerSupabaseClient } from '@supabase/auth-helpers-nextjs'import type { ParsedUrlQuery } from 'querystring'@@ -13,11 +12,13 @@ import {SystemPromptLog,UserPromptLog,AssistantPromptLog,+ AgentPromptLogs,+ AgentNextActionLog,} from 'utils/agentLogs'import AgentPrompLogDetail from 'components/AgentPromptLogDetail'import AgentPromptLogsList from 'components/AgentPromptLogsList'-import { alwaysTrue } from 'utils/positive'import AgentNextActionLogDetail from 'components/AgentNextActionLogDetail'+import { alwaysTrue } from 'utils/positive'interface PathProps extends ParsedUrlQuery {logFileID: string