Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

basic agent runs view

Vasek Mlejnsky4a2fda25f8a8
diff --git a/components/AgentList.tsx b/components/AgentList.tsx
index 0fbb6d6d8..2e780c7ce 100644
--- a/components/AgentList.tsx
+++ b/components/AgentList.tsx
@@ -19,7 +19,7 @@ function AgentList({
}: Props) {
return (
<main className="overflow-hidden">
- <header className="flex items-center justify-between border-b border-white/5 p-4 sm:p-6 lg:px-8">
+ <header className="flex items-center justify-between p-4 sm:p-6 lg:px-8">
<h1 className="text-2xl font-semibold leading-7 text-white">Deployed Agents</h1>
</header>
diff --git a/components/AgentRunsList.tsx b/components/AgentRunsList.tsx
index 095ac8f4a..b747de4b1 100644
--- a/components/AgentRunsList.tsx
+++ b/components/AgentRunsList.tsx
@@ -1,33 +1,137 @@
+import {
+ useState,
+} from 'react'
+import {
+ ChevronRight,
+} from 'lucide-react'
+import clsx from 'clsx'
+import { useRouter } from 'next/router'
+
import { deployments, projects } from 'db/prisma'
export interface Props {
- agentInstance: (projects & { deployments: deployments[] })
+ allDeployedAgents: {
+ project: projects & { deployments: deployments[] }
+ deployment: deployments
+ }[]
+ initialSelectedAgentID?: string
+ // agentInstance: {
+ // project: projects & { deployments: deployments[] }
+ // deployment: deployments
+ // }
}
function AgentRunsList({
- agentInstance,
+ allDeployedAgents,
+ initialSelectedAgentID,
}: Props) {
- console.log('agentInstance', agentInstance)
- // TODO: We'll have a better concept for run, challenge, task, benchmark, etc
- // once we give access to the AutoGPT team. Let's start with a simple version first.
- // At the moment, a run is just an array of logs with the same run ID.
- const runs = agentInstance.deployments.reduce((acc, d) => {
-
+ const router = useRouter()
+ const [selectedAgentID, setSelectedAgentID] = useState(initialSelectedAgentID || '')
+ const agentInstance = allDeployedAgents.find(a => a.project.id === selectedAgentID)
+ const runs = agentInstance?.deployment.logs.reduce((acc: any, l: any) => {
+ const runID = l['properties']['run_id']
+ if (!acc[runID]) {
+ acc[runID] = []
+ } else {
+ acc[runID].push(l)
+ }
return acc
- }, [])
+ }, {})
+ // function getAgentRuns(agentInstance: any) {
+ // }
+
+
+
+
+
+
+ // agentInstance={projectsWithDeployments.find(p => p.project.id === selectedAgentInstanceID)!}
+
+ // TODO: If no agent instance was specified, display all instances and runs and make them foldabble.
+
+ // console.log('agentInstance', agentInstance)
+ // // TODO: We'll have a better concept for run, challenge, task, benchmark, etc
+ // // once we give SDK to the first users. Let's start with a simple version first.
+ // // At the moment, a run is just an array of logs with the same run ID.
+ // const runs = agentInstance.deployment.logs.reduce((acc: any, l: any) => {
+ // const runID = l['properties']['run_id']
+ // console.log('run ID', runID)
+ // console.log('log', l)
+ // console.log('acc', acc)
+ // if (!acc[runID]) {
+ // acc[runID] = []
+ // } else {
+ // acc[runID].push(l)
+ // }
+ // return acc
+ // }, {})
+
+ function toggleSelectedAgentID(projectID: string) {
+ if (selectedAgentID === projectID) {
+ setSelectedAgentID('')
+ router.push('/?view=runs', undefined, { shallow: true })
+ } else {
+ setSelectedAgentID(projectID)
+ router.push(`/?view=runs&projectID=${projectID}`, undefined, { shallow: true })
+ }
+ }
return (
- <main className="overflow-hidden">
- <header className="flex items-center justify-between border-b border-white/5 p-4 sm:p-6 lg:px-8">
- <h1 className="text-2xl font-semibold leading-7 text-white">{agentInstance.name}</h1>
+ <main className="overflow-hidden flex flex-col max-h-full">
+ <header className="flex items-center justify-between p-4 sm:p-6 lg:px-8">
+ <h1 className="text-2xl font-semibold leading-7 text-white">Agent Runs</h1>
</header>
- <ul role="list" className="px-4 sm:px-6 lg:px-8 space-y-4 overflow-auto">
- </ul>
- </main>
+ <div className="flex flex-col space-y-4">
+ {/* Each deployed agent */}
+ {allDeployedAgents.map((a) => (
+ <div key={a.project.id} className="flex flex-col space-y-2">
+ <div className="flex items-center space-x-2 px-4 sm:px-6 lg:px-8">
+ <div
+ className="p-1 cursor-pointer bg-gray-800 hover:bg-gray-700 transition-all rounded-md"
+ onClick={() => toggleSelectedAgentID(a.project.id)}
+ >
+ <ChevronRight size={15} className={clsx(
+ 'text-gray-400',
+ 'transition-all',
+ 'select-none',
+ selectedAgentID === a.project.id && 'rotate-90',
+ )} />
+ </div>
+ <span>{a.project.name} - {a.project.id} [TODO: Better name]</span>
+ </div>
+
+ {/* Each run */}
+ {selectedAgentID === a.project.id && (
+ <div className="pl-16 flex flex-col space-y-4">
+ {Object.keys(runs).map((runID: string) => (
+ <div key={runID} className="flex flex-col space-y-2">
+ <span>runID: {runID}</span>
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
+ ))}
+ </div>
+
+ {/* {Object.keys(runs).map((runID: any) => (
+ <div key={runID} className="px-4 sm:px-6 lg:px-8 flex flex-col">
+ <span>run: {runID}</span>
+ <ul
+ role="list"
+ className="px-4 sm:px-6 lg:px-8 space-y-4 overflow-auto max-h-[200px]"
+ >
+ {runs[runID].map((log: any) => (
+ <li key={log.id}>{log.message}</li>
+ ))}
+ </ul>
+ </div>
+ ))} */}
+ </main >
)
}
diff --git a/pages/agent/smol-developer/setup.tsx b/pages/agent/smol-developer/setup.tsx
index 4c6e57121..5c76b615b 100644
--- a/pages/agent/smol-developer/setup.tsx
+++ b/pages/agent/smol-developer/setup.tsx
@@ -141,8 +141,6 @@ function Setup() {
console.error('No instructions provided')
return
}
- console.log('DEPLOY AGENT', selectedRepository, instructions)
-
const modelConfig = getSmolDevModelConfig({})
try {
diff --git a/pages/index.tsx b/pages/index.tsx
index 706e55921..f4ebad476 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -1,5 +1,5 @@
import { useState, Fragment } from 'react'
-import type { GetServerSideProps } from 'next'
+import type { GetServerSideProps, Redirect } from 'next'
import Link from 'next/link'
import { createServerSupabaseClient } from '@supabase/auth-helpers-nextjs'
import { Dialog, Transition } from '@headlessui/react'
@@ -26,7 +26,7 @@ const navigation = [
icon: Zap,
},
{
- name: 'Run Queue',
+ name: 'Agent Runs',
view: 'runs',
icon: ListEnd,
},
@@ -110,10 +110,21 @@ export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {
// Show projects from all teams.
const projects = user.users_teams.flatMap(t => t.teams.projects)
+ // Select the 'deployed' view by default.
+ const view = ctx.query['view'] as string
+ let redirect: Redirect | undefined
+ if (!view) {
+ redirect = {
+ destination: '/?view=deployed',
+ permanent: false,
+ }
+ }
+
return {
props: {
projects,
- }
+ },
+ redirect,
}
}
@@ -128,8 +139,7 @@ function Home({ projects }: Props) {
const posthog = usePostHog()
const view = router.query.view as string | undefined
- const selectedAgentInstance = router.query.projectID as string | undefined
- console.log({ view, selectedAgentInstance })
+ const selectedAgentInstanceID = router.query.projectID as string | undefined
async function signOut() {
await supabaseClient.auth.signOut()
@@ -141,7 +151,6 @@ function Home({ projects }: Props) {
e.preventDefault()
posthog?.capture('selected deployed agent', { projectID: projectID })
router.push(`/?view=runs&projectID=${projectID}`, undefined, { shallow: true })
- // router.push(`/deployed/${projectID}`)
}
const projectsWithDeployments = projects
@@ -308,7 +317,7 @@ function Home({ projects }: Props) {
</div>
</div>
- <div className="xl:pl-72">
+ <div className="xl:pl-72 flex flex-col max-h-full">
{/* Mobile menu icon */}
<div className="xl:hidden sticky top-0 z-40 flex 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={() => setSidebarOpen(true)}>
@@ -322,9 +331,10 @@ function Home({ projects }: Props) {
agents={projectsWithDeployments}
onSelectAgent={selectAgent}
/>
- ) : view === 'runs' && selectedAgentInstance ? (
+ ) : view === 'runs' ? (
<AgentRunsList
- agentInstance={projects.find(p => p.id === selectedAgentInstance)!}
+ allDeployedAgents={projectsWithDeployments}
+ initialSelectedAgentID={selectedAgentInstanceID}
/>
) : (
<span>404</span>