Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add dashboard [WIP]
Tomas Valentaba4a448ff612
diff --git a/api-service/app.py b/api-service/app.pyindex b60e14250..40f9bd71a 100644--- a/api-service/app.py+++ b/api-service/app.py@@ -30,19 +30,19 @@ def check_token(token: str | None):@asynccontextmanagerasync def lifespan(app: FastAPI):- deployments = await db.get_deployments()- for deployment in deployments:- if (- deployment["enabled"]- and deployment.get("config", None)- and deployment.get("project_id", None)- ):- print("Restarting deployment", deployment["id"])- await deployment_manager.create_deployment(- deployment["id"],- deployment["project_id"],- deployment["config"],- )+ # deployments = await db.get_deployments()+ # for deployment in deployments:+ # if (+ # deployment["enabled"]+ # and deployment.get("config", None)+ # and deployment.get("project_id", None)+ # ):+ # print("Restarting deployment", deployment["id"])+ # await deployment_manager.create_deployment(+ # deployment["id"],+ # deployment["project_id"],+ # deployment["config"],+ # )yielddiff --git a/components/AgentOverview.tsx b/components/AgentOverview.tsxindex e53a44ca9..46d72cddd 100644--- a/components/AgentOverview.tsx+++ b/components/AgentOverview.tsx@@ -8,68 +8,82 @@ import clsx from 'clsx'import { Grid } from 'lucide-react'import { projects, deployments } from 'db/prisma'+import { useRouter } from 'next/router'const navigation = [{- name: 'Agents', href: '#', icon: Grid, current: false,+ name: 'Agents', href: '#', icon: Grid, current: true,},]const statuses = {- offline: 'text-gray-500 bg-gray-100/10',- online: 'text-green-400 bg-green-400/10',- error: 'text-rose-400 bg-rose-400/10',+ disabled: 'text-gray-500 bg-gray-100/10',+ enabled: 'text-green-400 bg-green-400/10',}const environments = {Preview: 'text-gray-400 bg-gray-400/10 ring-gray-400/20',Production: 'text-indigo-400 bg-indigo-400/10 ring-indigo-400/30',}-const deployments = [- {- id: 1,- href: '#',- projectName: 'smol-ai/developer',- teamName: 'Smol Agent',- status: 'offline',- statusText: 'Initiated 1m 32s ago',- description: 'Deployed to GitHub repository ValentaTomas/test',- environment: 'PR#11',- },- {- id: 2,- href: '#',- projectName: 'smol-ai/developer',- teamName: 'Smol Agent',- status: 'online',- statusText: 'Initiated 1m 32s ago',- description: 'Deployed to GitHub repository ValentaTomas/test',- environment: 'PR#12',- },-]-const activityItems = [- {- user: {- name: 'Michael Foster',- imageUrl:- 'https://images.unsplash.com/photo-1519244703995-f4e0f30006d5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80',+// const deployments = [+// {+// id: 1,+// href: '#',+// projectName: 'smol-ai/developer',+// teamName: 'Smol Agent',+// status: 'offline',+// statusText: 'Initiated 1m 32s ago',+// description: 'Deployed to GitHub repository ValentaTomas/test',+// environment: 'PR#11',+// },+// {+// id: 2,+// href: '#',+// projectName: 'smol-ai/developer',+// teamName: 'Smol Agent',+// status: 'online',+// statusText: 'Initiated 1m 32s ago',+// description: 'Deployed to GitHub repository ValentaTomas/test',+// environment: 'PR#12',+// },+// ]++export interface DeleteProjectBody {+ id: string+}++async function handleDeleteProject(url: string, { arg }: { arg: DeleteProjectBody }) {+ return await fetch(url, {+ method: 'DELETE',+ body: JSON.stringify(arg),+ headers: {+ 'Content-Type': 'application/json',},- projectName: 'ios-app',- commit: '2d89f0c8',- branch: 'main',- date: '1h',- dateTime: '2023-01-23T11:00',- },- // More items...-]+ }).then(r => r.json())+}+export interface Props {projects: (projects & { deployments: deployments[] })[]}export default function AgentOverview({ projects }: Props) {- const projectWithDeployments = projects- .filter(p => p.deployments.length > 0)-const [sidebarOpen, setSidebarOpen] = useState(false)+ const router = useRouter()++ const {+ trigger: deleteProject,+ } = useSWRMutation('/api/project', handleDeleteProject)++ async function handleDelete(id: string) {+ await deleteProject({ id })+ router.replace(router.asPath)+ }++ const projectsWithDeployments = projects+ .filter(p => p.deployments.length === 1 && p.deployments[0].auth !== null)+ .map(p => ({+ project: p,+ deployment: p.deployments[0],+ }))return (<div>@@ -223,38 +237,38 @@ export default function AgentOverview({ projects }: Props) {{/* Deployment list */}<ul role="list" className="divide-y divide-white/5">- {deployments.map((deployment) => (- <li key={deployment.id} className="relative flex items-center space-x-4 p-4 sm:px-6 lg:px-8">+ {projectsWithDeployments.map((p) => (+ <li key={p.project.id} className="relative flex items-center space-x-4 p-4 sm:px-6 lg:px-8"><div className="min-w-0 flex-auto"><div className="flex items-center gap-x-3">- <div className={clsx(statuses[deployment.status as keyof typeof statuses], 'flex-none rounded-full p-1')}>+ <div className={clsx(statuses[p.deployment.enabled ? 'enabled' : 'disabled'], 'flex-none rounded-full p-1')}><div className="h-2 w-2 rounded-full bg-current" /></div><h2 className="min-w-0 text-sm font-semibold leading-6 text-white">- <a href={deployment.href} className="flex gap-x-2">- <span className="truncate">{deployment.teamName}</span>+ <a className="flex gap-x-2">+ <span className="truncate">{p.project.name}</span><span className="text-gray-400">-</span>- <span className="whitespace-nowrap">{deployment.projectName}</span>+ <span className="whitespace-nowrap">{(p.deployment?.auth as any)?.['github']?.['owner'] + '/' + (p.deployment?.auth as any)?.['github']?.['repo']}</span><span className="absolute inset-0" /></a></h2></div><div className="mt-3 flex items-center gap-x-2.5 text-xs leading-5 text-gray-400">- <p className="truncate">{deployment.description}</p>+ <p className="truncate">{`PR#${(p.deployment?.auth as any)?.['github']?.['pull_number']}`}</p><svg viewBox="0 0 2 2" className="h-0.5 w-0.5 flex-none fill-gray-300"><circle cx={1} cy={1} r={1} /></svg>- <p className="whitespace-nowrap">{deployment.statusText}</p>+ {/* <p className="whitespace-nowrap">{p.statusText}</p> */}</div></div>- <div+ {/* <divclassName={clsx(- environments[deployment.environment as keyof typeof environments],+ environments[p.environment as keyof typeof environments],'rounded-full flex-none py-1 px-2 text-xs font-medium ring-1 ring-inset')}>- {deployment.environment}- </div>+ {p.environment}+ </div> */}<ChevronRightIcon className="h-5 w-5 flex-none text-gray-400" aria-hidden="true" /></li>))}@@ -262,6 +276,9 @@ export default function AgentOverview({ projects }: Props) {</main></div>- </div>+ </div >)}+function useSWRMutation(arg0: string, handleDeleteProject: (url: string, { arg }: { arg: DeleteProjectBody }) => Promise<any>): { trigger: any } {+ throw new Error('Function not implemented.')+}diff --git a/pages/api/project.ts b/pages/api/project.tsindex b2e62b0b7..e72fa79fd 100644--- a/pages/api/project.ts+++ b/pages/api/project.ts@@ -3,7 +3,7 @@ import { NextApiRequest, NextApiResponse } from 'next'import { prisma } from 'db/prisma'import { serverCreds } from 'db/credentials'-import type { DeleteProjectBody } from 'pages'+import type { DeleteProjectBody } from 'components/AgentOverview'async function deleteProject(req: NextApiRequest, res: NextApiResponse) {const { id } = req.body as DeleteProjectBodydiff --git a/pages/index.tsx b/pages/index.tsxindex ed8ee24c1..cbd24ed5d 100644--- a/pages/index.tsx+++ b/pages/index.tsx@@ -1,7 +1,5 @@import type { GetServerSideProps } from 'next'-import useSWRMutation from 'swr/mutation'import { createServerSupabaseClient } from '@supabase/auth-helpers-nextjs'-import { useRouter } from 'next/router'import AgentOverview from 'components/AgentOverview'import { deployments, prisma, projects } from 'db/prisma'@@ -97,35 +95,11 @@ export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {}}-export interface DeleteProjectBody {- id: string-}--async function handleDeleteProject(url: string, { arg }: { arg: DeleteProjectBody }) {- return await fetch(url, {- method: 'DELETE',- body: JSON.stringify(arg),- headers: {- 'Content-Type': 'application/json',- },- }).then(r => r.json())-}-interface Props {projects: (projects & { deployments: deployments[] })[]}function Home({ projects }: Props) {- const router = useRouter()-- const {- trigger: deleteProject,- } = useSWRMutation('/api/project', handleDeleteProject)-- async function handleDelete(id: string) {- await deleteProject({ id })- router.replace(router.asPath)- }return (<AgentOverview