Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Fetch all log file content in the initial request
Tomas Valenta842cc343f05a
diff --git a/components/AgentLogFileContent.tsx b/components/AgentLogFileContent.tsxindex 648da2216..f2dde9680 100644--- a/components/AgentLogFileContent.tsx+++ b/components/AgentLogFileContent.tsx@@ -18,7 +18,7 @@ import AgentPromptLogsList from 'components/AgentPromptLogsList'import AgentNextActionLogDetail from 'components/AgentNextActionLogDetail'export interface Props {- logFile?: Omit<log_files, 'content'> & { content: AgentPromptLogs | AgentNextActionLog }+ logFile?: Omit<log_files, 'project_id' | 'type' | 'size' | 'log_upload_id' | 'content'> & { content: AgentPromptLogs | AgentNextActionLog }}function AgentLogFileContent({diff --git a/components/AgentLogFilesList.tsx b/components/AgentLogFilesList.tsxindex 8acb04951..820c8df84 100644--- a/components/AgentLogFilesList.tsx+++ b/components/AgentLogFilesList.tsx@@ -34,7 +34,7 @@ function AgentLogFilesList({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 [selectedLogFile, setSelectedLogFile] = useState<Omit<log_files, 'project_id' | 'type' | 'size' | 'log_upload_id' | 'content'> & { content: AgentPromptLogs | AgentNextActionLog }>()const router = useRouter()const fileInput = useRef<HTMLInputElement>(null)const uploadFiles = useUploadLogs(defaultProjectID)@@ -115,37 +115,40 @@ function AgentLogFilesList({return `/?${new URLSearchParams(query).toString()}`}- async function selectLogFile(logFileID: string) {+ async function selectLogFile(logFile: any) {// Log files in logUploads don't have content. We fetch the full log file lazily.- const logFile = await getLogFile(logFileID)- if (!logFile) return+ // setSelectedLogFile()- const parsedFileContent = JSON.parse(logFile.content)+ // const logFile = await getLogFile(logFileID)+ // if (!logFile) return- // 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,- },- })- }++ // 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 (@@ -252,7 +255,9 @@ function AgentLogFilesList({<Linkhref={logFileURL(logFile.id)}shallow={true}- onClick={() => selectLogFile(logFile.id)}+ onClick={() => {+ setSelectedLogFile(logFile)+ }}>{logFile.relativePath.split('/').map(p => (<span key={p}>{'/ '}{p}</span>diff --git a/components/index.html b/components/index.htmldeleted file mode 100644index af011b4de..000000000--- a/components/index.html+++ /dev/null@@ -1 +0,0 @@-<!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/pages/api/log_file/[:logFileID].ts b/pages/api/log_file/[:logFileID].tsindex 2ffb79e11..cae1b63b5 100644--- a/pages/api/log_file/[:logFileID].ts+++ b/pages/api/log_file/[:logFileID].ts@@ -9,6 +9,8 @@ async function getLog(req: NextApiRequest, res: NextApiResponse) {':logFileID': logFileID,} = req.query+ console.log('getting log >>>>')+try {if (!logFileID) {res.status(400).json({ statusCode: 400, message: 'Missing log ID in URL' })diff --git a/pages/index.tsx b/pages/index.tsxindex 54da40a52..56d682e85 100644--- a/pages/index.tsx+++ b/pages/index.tsx@@ -3,10 +3,10 @@ import { createServerSupabaseClient } from '@supabase/auth-helpers-nextjs'import { nanoid } from 'nanoid'import path from 'path'-import { prisma, projects, deployments } from 'db/prisma'+import { prisma, projects, deployments, log_files } from 'db/prisma'import { serverCreds } from 'db/credentials'import DashboardHome from 'components/DashboardHome'-import { LiteLogUpload } from 'utils/agentLogs'+import { AgentNextActionLog, AgentPromptLogs, LiteLogUpload } from 'utils/agentLogs'function getLastTwoDirsAndFile(fullPath: string): string {const fileName = path.basename(fullPath)@@ -18,6 +18,38 @@ function getLastTwoDirsAndFile(fullPath: string): string {return path.join(lastTwoDirs, fileName)}+function formatLogFileContent(logFile: Omit<log_files, 'project_id' | 'type' | 'size' | 'log_upload_id'>) {+ const parsedFileContent = JSON.parse(logFile.content)+ const relativePath = getLastTwoDirsAndFile(logFile.relativePath)++ // Specific to AutoGPT+ if (logFile.filename.includes('next_action')) {+ return {+ ...logFile,+ relativePath,+ content: parsedFileContent as AgentNextActionLog,+ }+ }+ if (logFile.filename.includes('full_message_history') || logFile.filename.includes('current_context')) {+ return {+ ...logFile,+ relativePath,+ content: {+ logs: parsedFileContent as AgentPromptLogs,+ },+ }+ }+ return {+ ...logFile,+ relativePath,+ content: {+ ...parsedFileContent,+ logs: parsedFileContent?.context || [],+ context: undefined,+ },+ }+}+export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {// Select the 'deployed' view by default.const view = ctx.query['view'] as string@@ -57,6 +89,9 @@ export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {id: true,is_default: true,projects: {+ where: {+ is_default: true,+ },include: {log_uploads: {select: {@@ -69,6 +104,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {filename: true,last_modified: true,relativePath: true,+ content: true,},},},@@ -180,10 +216,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {.log_uploads.map<LiteLogUpload>(u => ({...u,- log_files: u.log_files.map(f => ({- ...f,- relativePath: getLastTwoDirsAndFile(f.relativePath),- })),+ log_files: u.log_files.map(formatLogFileContent),}))}))},diff --git a/pages/log/[logFileID].tsx b/pages/log/[logFileID].tsxindex 5e97876f0..d5f9e0f6b 100644--- a/pages/log/[logFileID].tsx+++ b/pages/log/[logFileID].tsx@@ -96,7 +96,7 @@ export const getServerSideProps: GetServerSideProps<Props, PathProps> = async (clogFile: {...logFile,content: {- logs: parsedFileContent as AgentNextActionLog,+ logs: parsedFileContent as AgentPromptLogs,},},},diff --git a/utils/agentLogs.ts b/utils/agentLogs.tsindex 4dc53c7e0..827630890 100644--- a/utils/agentLogs.ts+++ b/utils/agentLogs.ts@@ -1,7 +1,7 @@import { log_files, log_uploads } from 'db/prisma'export interface LiteLogUpload extends Omit<log_uploads, 'log_files' | 'project_id'> {- log_files: Omit<log_files, 'content' | 'project_id' | 'type' | 'size' | 'log_upload_id'>[]+ log_files: (Omit<log_files, 'project_id' | 'type' | 'size' | 'log_upload_id' | 'content'> & { content: AgentPromptLogs | AgentNextActionLog })[]}export interface AgentPromptLogs {