Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Deploy page
Vasek Mlejnsky9d42e2b43276
diff --git a/components/AgentInstructions.tsx b/components/AgentInstructions.tsxindex 2fbd380af..615917e8f 100644--- a/components/AgentInstructions.tsx+++ b/components/AgentInstructions.tsx@@ -1,12 +1,20 @@+import {+ useRef,+ useState,+} from 'react'import {ArrowLeft,} from 'lucide-react'-import InstructionsEditor from 'components/Editor/Template/NodeJSExpressTemplate/InstructionsEditor'+import smolTemplates from 'utils/smolTemplates'+import InstructionsEditor, { InstructionsEditorRef } from 'components/Editor/Template/NodeJSExpressTemplate/InstructionsEditor'+import InstructionsTemplateButton from 'components/InstructionsTemplateButton'+import AlertError from 'components/AlertError'export interface Props {value: stringonChange: (value: string) => void+ onTemplateSelect: (template: string) => voidonBack: () => voidonNext: () => void}@@ -14,14 +22,53 @@ export interface Props {function AgentInstructions({value,onChange,+ onTemplateSelect,onBack,onNext,}: Props) {+ const [error, setError] = useState<{ title: string, infoItems: string[] }>()+ const editorRef = useRef<InstructionsEditorRef>(null)++ function handleContinue() {+ setError(undefined)+ if (!value) {+ setError({+ title: 'No instructions provided',+ infoItems: [+ 'Please provide instructions for the AI developer to follow',+ ],+ })+ return+ }+ onNext()+ }++ function handleTemplateClick(template: string) {+ editorRef.current?.setContent(template)+ onTemplateSelect(template)+ }+return (<div className="flex-1 flex flex-col items-start justify-start space-y-2"><h3 className="text-white font-bold">What do you want the AI developer to build?</h3>+ {error && (+ <AlertError+ title={error.title}+ infoItems={error.infoItems}+ />+ )}+ <div className="flex items-center gap-2 flex-wrap">+ {Object.keys(smolTemplates).map((key) => (+ <InstructionsTemplateButton+ key={key}+ text={smolTemplates[key].title}+ onClick={() => handleTemplateClick(smolTemplates[key].content)}+ />+ ))}+ </div><div className="relative bg-gray-950 flex flex-col p-2 w-full flex-1 overflow-auto border border-gray-700 rounded-md"><InstructionsEditor+ ref={editorRef}className="absolute inset-0 bg-gray-950 p-4 text-gray-100"placeholder="Create a website using Nextjs..."content={value}@@ -37,8 +84,8 @@ function AgentInstructions({<span className="text-sm">Back</span></button><button- className="px-2 py-1 font-medium rounded-md text-sm border border-transparent bg-indigo-600/30 text-indigo-500 hover:bg-transparent hover:border-indigo-600 transition-all"- onClick={onNext}+ className="px-2 py-1 font-medium rounded-md text-sm border border-indigo-400/30 bg-indigo-400/10 text-indigo-400 hover:bg-transparent hover:border-indigo-400 transition-all"+ onClick={handleContinue}>Continue</button>diff --git a/components/AlertError.tsx b/components/AlertError.tsxindex 217040450..749336916 100644--- a/components/AlertError.tsx+++ b/components/AlertError.tsx@@ -10,12 +10,12 @@ function AlertError({infoItems,}: Props) {return (- <div className="rounded-md bg-red-50 p-4 max-w-full">- <div className="flex overflow-auto">- <div className="shrink-0">+ <div className="rounded-md bg-red-50 p-4 max-w-full w-full">+ <div className="flex items-start space-x-3 overflow-auto">+ <div className="relative top-[2px]"><XCircle className="text-red-400" size={16} aria-hidden="true" /></div>- <div className="ml-3">+ <div className="flex flex-col items-start justify-start"><h3 className="text-sm font-medium text-red-800">{title}</h3><div className="mt-2 text-sm text-red-700"><ul role="list" className="list-disc space-y-1 pl-5">diff --git a/components/DeployAgent.tsx b/components/DeployAgent.tsxnew file mode 100644index 000000000..cb2f17404--- /dev/null+++ b/components/DeployAgent.tsx@@ -0,0 +1,122 @@+import {+ Github,+ ArrowLeft,+ ScrollText,+} from 'lucide-react'++import InstructionsEditor from 'components/Editor/Template/NodeJSExpressTemplate/InstructionsEditor'+import { RepoSetup } from 'utils/repoSetup'+import SpinnerIcon from 'components/Spinner'++export interface Props {+ selectedRepo: RepoSetup;+ instructions: string+ onInstructionsChange: (value: string) => void+ onChangeTemplate: (e: any) => void+ onChangeRepo: (e: any) => void+ onBack: (e: any) => void+ onDeploy: (e: any) => void+ isDeploying?: boolean+ error?: string+}++function DeployAgent({+ selectedRepo,+ instructions,+ onInstructionsChange,+ onChangeTemplate,+ onChangeRepo,+ onBack,+ onDeploy,+ isDeploying,+ error,+}: Props) {+ return (+ <div className="flex-1 flex flex-col items-start justify-start space-y-2">+ <div className="flex-1 w-full flex flex-col items-start justify-start space-y-8">++ {isDeploying && (+ <div className="flex-1 w-full flex space-x-2 items-center justify-center">+ <SpinnerIcon className="text-gray-300" />+ <span className="text-gray-300">Deploying...</span>+ </div>+ )}++ {!isDeploying && (+ <>+ {/* Selected repo */}+ <div className="w-full flex flex-col space-y-2 items-start justify-start">+ <div className="w-full flex items-center justify-between">+ <div className="flex items-center space-x-1">+ <Github className="text-gray-300" size={16} />+ <span className="text-sm text-gray-300 font-medium">+ Repository+ </span>+ </div>++ <button+ type="button"+ className="rounded w-[136px] bg-white/10 px-2 py-1 text-xs font-semibold text-white shadow-sm hover:bg-white/20"+ onClick={onChangeRepo}+ >+ Change Repository+ </button>+ </div>++ <span className="text-sm font-medium text-gray-100">+ {selectedRepo.fullName}+ </span>+ </div>++ <hr className="w-full border-gray-700 rounded" />++ {/* Instructions */}+ <div className="flex-1 w-full flex flex-col space-y-2 items-start justify-start">+ <div className="w-full flex items-center justify-between">+ <div className="flex items-center space-x-1">+ <ScrollText className="text-gray-300" size={16} />+ <span className="text-sm text-gray-300 font-medium">+ Instructions+ </span>+ </div>+ <button+ type="button"+ className="rounded w-[136px] bg-white/10 px-2 py-1 text-xs font-semibold text-white shadow-sm hover:bg-white/20"+ onClick={onChangeTemplate}+ >+ Use Template+ </button>+ </div>++ <div className="relative bg-gray-950 flex flex-col p-2 w-full flex-1 overflow-auto border border-gray-700 rounded-md">+ <InstructionsEditor+ className="absolute inset-0 bg-gray-950 p-4 text-gray-100"+ content={instructions}+ onChange={onInstructionsChange}+ />+ </div>+ </div>+ <div className="w-full flex items-center justify-between">+ <button+ className="flex items-center justify-start space-x-1 text-gray-400 hover:text-gray-100 transition-all"+ onClick={onBack}+ >+ <ArrowLeft size={14} />+ <span className="text-sm">Back</span>+ </button>+ <button+ className="px-2 py-1 font-medium rounded-md text-sm border border-green-400/30 bg-green-400/10 text-green-400 hover:bg-transparent hover:border-green-400 transition-all"+ onClick={onDeploy}+ >+ Deploy on <b>e2b</b>+ </button>+ </div>+ </>+ )}++ </div>+ </div>+ )+}++export default DeployAgent\ No newline at end of filediff --git a/components/Editor/Template/NodeJSExpressTemplate/InstructionsEditor/index.tsx b/components/Editor/Template/NodeJSExpressTemplate/InstructionsEditor/index.tsxindex a08dbb9c0..74dabdfb3 100644--- a/components/Editor/Template/NodeJSExpressTemplate/InstructionsEditor/index.tsx+++ b/components/Editor/Template/NodeJSExpressTemplate/InstructionsEditor/index.tsx@@ -1,3 +1,7 @@+import {+ forwardRef,+ useImperativeHandle,+} from 'react'import { EditorContent } from '@tiptap/react'import Fuse from 'fuse.js'import clsx from 'clsx'@@ -15,20 +19,32 @@ export interface Props {referenceSearch?: Fuse<Reference>}-function InstructionsEditor({+export interface InstructionsEditorRef {+ setContent: (content: string) => void+}++const InstructionsEditor = forwardRef<InstructionsEditorRef, Props>(function InstructionsEditor({className,title,onChange,content,placeholder,referenceSearch,-}: Props) {+}: Props, ref) {const editor = useDocEditor({initialContent: content,onContentChange: onChange,placeholder,})+ useImperativeHandle(ref, () => {+ return {+ setContent(content: string) {+ editor?.commands.setContent(content)+ }+ }+ })+return (<div className={clsx('flex flex-col space-y-2 self-stretch pb-6', 'instructions-editor', className)}>{title &&@@ -43,6 +59,6 @@ function InstructionsEditor({/></div>)-}+})export default InstructionsEditordiff --git a/components/InstructionsTemplateButton.tsx b/components/InstructionsTemplateButton.tsxnew file mode 100644index 000000000..e839fc6e8--- /dev/null+++ b/components/InstructionsTemplateButton.tsx@@ -0,0 +1,20 @@+export interface Props {+ text: string+ onClick: () => void+}++function InstructionsTemplateButton({+ text,+ onClick,+}: Props) {+ return (+ <button+ className="flex items-center rounded-md bg-indigo-400/10 active:bg-indigo-400/20 px-2 py-1 text-xs font-medium text-indigo-400 border border-indigo-400/30 hover:border-indigo-400 cursor-pointer transition-all whitespace-nowrap"+ onClick={onClick}+ >+ {text}+ </button>+ )+}++export default InstructionsTemplateButtondiff --git a/components/SelectRepository/ExistingRepositories/RepositoriesList.tsx b/components/SelectRepository/ExistingRepositories/RepositoriesList.tsxindex 12ae9660f..b089c590f 100644--- a/components/SelectRepository/ExistingRepositories/RepositoriesList.tsx+++ b/components/SelectRepository/ExistingRepositories/RepositoriesList.tsx@@ -1,7 +1,8 @@import {Github,} from 'lucide-react'-import { Repos, RepoSetup } from '../RepoSetup'++import { Repos, RepoSetup } from 'utils/repoSetup'export interface Props {repos: Reposdiff --git a/components/SelectRepository/ExistingRepositories/index.tsx b/components/SelectRepository/ExistingRepositories/index.tsxindex 89eb1910f..984371d05 100644--- a/components/SelectRepository/ExistingRepositories/index.tsx+++ b/components/SelectRepository/ExistingRepositories/index.tsx@@ -1,8 +1,10 @@import clsx from 'clsx'+import ConfigureGitHubButton from 'components/ConfigureGitHubButton'import SpinnerIcon from 'components/Spinner'+import { RepoSetup, Repos } from 'utils/repoSetup'+import RepositoriesList from './RepositoriesList'-import { RepoSetup, Repos } from '../RepoSetup'export interface Props {accessToken?: stringdiff --git a/components/SelectRepository/NewRepository/index.tsx b/components/SelectRepository/NewRepository/index.tsxindex 4db6f4616..773eaf13f 100644--- a/components/SelectRepository/NewRepository/index.tsx+++ b/components/SelectRepository/NewRepository/index.tsx@@ -13,6 +13,7 @@ import {import { useGitHubClient } from 'hooks/useGitHubClient'import SpinnerIcon from 'components/Spinner'import { createRepo } from 'github/repo'+import { RepoSetup } from 'utils/repoSetup'import RepoAccountSelect from './RepoAccountSelect'import RepoNameInput from './RepoNameInput'@@ -21,7 +22,6 @@ import {creationReducer,ActionType,} from './newRepoState'-import { RepoSetup } from '../RepoSetup'export interface Props {accessToken?: stringdiff --git a/components/SelectRepository/RepoSwitch.tsx b/components/SelectRepository/RepoSwitch.tsxindex f63545dd4..73d083bb0 100644--- a/components/SelectRepository/RepoSwitch.tsx+++ b/components/SelectRepository/RepoSwitch.tsx@@ -6,8 +6,8 @@ export interface Props {}const baseClasses = 'text-xs font-semibold p-2 rounded-md transition-all cursor-pointer'-const unselectedClasses = 'text-gray-500 hover:bg-indigo-600/30 hover:text-indigo-400'-const selectedClasses = 'bg-indigo-600/30 text-indigo-400'+const unselectedClasses = 'text-gray-500 hover:bg-indigo-400/10 hover:text-indigo-400'+const selectedClasses = 'bg-indigo-400/10 text-indigo-400'function RepoSwitch({value,diff --git a/components/SelectRepository/index.tsx b/components/SelectRepository/index.tsxindex e0858a8d4..beae10665 100644--- a/components/SelectRepository/index.tsx+++ b/components/SelectRepository/index.tsx@@ -13,8 +13,8 @@ import {GitHubAccount,} from 'utils/github'import SpinnerIcon from 'components/Spinner'+import { RepoSetup, Repos } from 'utils/repoSetup'-import { RepoSetup, Repos } from './RepoSetup'import RepoSwitch from './RepoSwitch'import ExistingRepositories from './ExistingRepositories'import NewRepository from './NewRepository'diff --git a/components/Steps.tsx b/components/Steps.tsxindex acd314388..62913838b 100644--- a/components/Steps.tsx+++ b/components/Steps.tsx@@ -1,27 +1,35 @@export interface Props {- steps: { name: string, status: string }[]+ currentIdx: number,+ steps: { name: string }[]}function Steps({+ currentIdx,steps,}: Props) {- const currentName = steps.find(s => s.status === 'current')?.name+ const currentStep = steps.find((s, idx) => idx === currentIdx)return (<div className="px-px w-full flex items-center justify-center"><ol role="list" className="w-full flex items-center space-x-5 mr-1 mt-0.5"><div className="w-full flex items-center justify-between">- <span className="text-xs font-medium text-white">{currentName}</span>+ <span className="text-xs font-medium text-white">{currentStep?.name}</span><p className="text-gray-400 text-xs font-medium">- Step {steps.findIndex((step) => step.status === 'current') + 1} of {steps.length}+ Step {currentIdx + 1} of {steps.length}</p></div>- {steps.map((step) => (+ {steps.map((step, idx) => (<li key={step.name}>- {step.status === 'complete' ? (+ {idx < currentIdx ? (+ // Completed step<div className="block h-2.5 w-2.5 rounded-full bg-indigo-500"><span className="sr-only">{step.name}</span></div>- ) : step.status === 'current' ? (+ ) : idx > currentIdx ? (+ <div className="block h-2.5 w-2.5 rounded-full bg-white/5 ring-1 ring-white/10">+ <span className="sr-only">{step.name}</span>+ </div>+ ) : (+ // Current step<div className="relative flex items-center justify-center"><span className="absolute flex h-5 w-5 p-px"><span className="h-full w-full rounded-full bg-indigo-600/30 ring-1 ring-inset ring-indigo-500/20" />@@ -29,10 +37,6 @@ function Steps({<span className="relative block h-2.5 w-2.5 rounded-full bg-indigo-500" /><span className="sr-only">{step.name}</span></div>- ) : (- <div className="block h-2.5 w-2.5 rounded-full bg-white/5 ring-1 ring-white/10">- <span className="sr-only">{step.name}</span>- </div>)}</li>))}diff --git a/package-lock.json b/package-lock.jsonindex ea0d27621..873855954 100644--- a/package-lock.json+++ b/package-lock.json@@ -35,7 +35,7 @@"human-id": "^4.0.0","immer": "^9.0.19","jsonpath-plus": "^7.2.0",- "lucide-react": "^0.161.0",+ "lucide-react": "^0.240.0","micro-cors": "^0.1.1","mustache": "^4.2.0","nanoid": "^4.0.1",@@ -5063,9 +5063,9 @@}},"node_modules/lucide-react": {- "version": "0.161.0",- "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.161.0.tgz",- "integrity": "sha512-Yr0VR0l6r+t65JCE9q+rTMItWqbhF4Wn3l73PHMwxves2wDhEPH7V2JqxvqS0In/brIwiyBV90++r/rHxNK9ug==",+ "version": "0.240.0",+ "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.240.0.tgz",+ "integrity": "sha512-75lFCbrvSs1ixJUwDN2XLcUTMUIRV8bN/TrBjZdcGHIZNoczLQRnb7zJSvzZhCFyMymT6pXNBB61oaE1JerlrA==","peerDependencies": {"react": "^16.5.1 || ^17.0.0 || ^18.0.0"}diff --git a/package.json b/package.jsonindex 8db05c06e..b84a6d560 100644--- a/package.json+++ b/package.json@@ -65,7 +65,7 @@"human-id": "^4.0.0","immer": "^9.0.19","jsonpath-plus": "^7.2.0",- "lucide-react": "^0.161.0",+ "lucide-react": "^0.240.0","micro-cors": "^0.1.1","mustache": "^4.2.0","nanoid": "^4.0.1",diff --git a/pages/agent/smol-developer/setup.tsx b/pages/agent/smol-developer/setup.tsxindex 703096577..20fbcab66 100644--- a/pages/agent/smol-developer/setup.tsx+++ b/pages/agent/smol-developer/setup.tsx@@ -10,10 +10,12 @@ import {useUser,useSupabaseClient,} from '@supabase/auth-helpers-react'+import { nanoid } from 'nanoid'import Steps from 'components/Steps'import SelectRepository from 'components/SelectRepository'import AgentInstructions from 'components/AgentInstructions'+import DeployAgent from 'components/DeployAgent'import { serverCreds } from 'db/credentials'import { useGitHubClient } from 'hooks/useGitHubClient'import { useRepositories } from 'hooks/useRepositories'@@ -23,8 +25,7 @@ import { TemplateID } from 'state/template'import { Creds } from 'hooks/useModelProviderArgs'import { getDefaultModelConfig, getModelArgs, ModelConfig } from 'state/model'import { GitHubAccount } from 'utils/github'-import { RepoSetup } from 'components/SelectRepository/RepoSetup'-import { nanoid } from 'nanoid'+import { RepoSetup } from 'utils/repoSetup'export interface PostAgentBody {// ID of the installation of the GitHub App@@ -49,9 +50,9 @@ export interface PostAgentBody {}const steps = [- { name: 'Select Repository', status: 'current' },- { name: 'Your Instructions', status: 'upcoming' },- { name: 'Deploy AI Developer', status: 'upcoming' },+ { name: 'Select Repository' },+ { name: 'Your Instructions' },+ { name: 'Overview & Deploy' },]export const getServerSideProps: GetServerSideProps = async (ctx) => {@@ -108,11 +109,12 @@ function Setup() {const [accessToken, setAccessToken] = useLocalStorage<string | undefined>('gh_access_token', undefined)const github = useGitHubClient(accessToken)const [githubAccounts, setGitHubAccounts] = useState<GitHubAccount[]>([])- const [currentStep, setCurrentStep] = useState(0)+ const [currentStepIdx, setCurrentStepIdx] = useState(0)const [selectedRepository, setSelectedRepository] = useState<RepoSetup>()const { repos, refetch } = useRepositories(github)const [instructions, setInstructions] = useState('')const [openAIAPIKey, setOpenAIAPIKey] = useState('')+ const [isDeploying, setIsDeploying] = useState(false)const handleMessageEvent = useCallback((event: MessageEvent) => {if (event.data.accessToken) {@@ -140,7 +142,6 @@ function Setup() {console.error('No OpenAI API key provided')return}- console.log('DEPLOY AGENT', selectedRepository, instructions, openAIAPIKey)const modelConfig = getSmolDevModelConfig({OpenAI: {@@ -150,6 +151,8 @@ function Setup() {},})+ setIsDeploying(true)+await createAgent({defaultBranch: selectedRepository.defaultBranch,installationID: selectedRepository.installationID,@@ -162,24 +165,16 @@ function Setup() {commitMessage: 'Smol dev initial commit',modelConfig,})+ setIsDeploying(false)+ // TODO: Redirect to the dashboard.}function nextStep() {- setCurrentStep(val => {- const newVal = val + 1- steps[val].status = 'complete'- steps[newVal].status = 'current'- return newVal- })+ setCurrentStepIdx(currentStepIdx + 1)}function previousStep() {- setCurrentStep(val => {- const newVal = val - 1- steps[val].status = 'upcoming'- steps[newVal].status = 'current'- return newVal- })+ setCurrentStepIdx(currentStepIdx - 1)}function handleRepoSelection(repo: any) {@@ -223,9 +218,12 @@ function Setup() {</button></div><div className="overflow-hidden flex-1 mx-auto w-full max-w-lg flex flex-col">- <Steps steps={steps} />+ <Steps+ currentIdx={currentStepIdx}+ steps={steps}+ /><div className="h-px bg-gray-700 my-8" />- {currentStep === 0 && (+ {currentStepIdx === 0 && (<SelectRepositoryrepos={repos}onRepoSelection={handleRepoSelection}@@ -233,23 +231,26 @@ function Setup() {githubAccounts={githubAccounts}/>)}- {currentStep === 1 && (+ {currentStepIdx === 1 && (<AgentInstructionsvalue={instructions}+ onTemplateSelect={t => { console.log(t); setInstructions(t) }}onChange={setInstructions}onBack={previousStep}onNext={nextStep}/>)}- {currentStep === 2 && (- <div>- <button- className="w-8 min-w-[64px] h-[24px] min-h-[24px] flex items-center justify-center rounded bg-white/10 px-2 py-1 text-sm text-white font-medium hover:bg-white/20"- onClick={deployAgent}- >- <span>Deploy</span>- </button>- </div>+ {currentStepIdx === 2 && (+ <DeployAgent+ selectedRepo={selectedRepository!}+ instructions={instructions}+ onInstructionsChange={setInstructions}+ onChangeRepo={() => setCurrentStepIdx(0)}+ onChangeTemplate={() => setCurrentStepIdx(1)}+ onBack={previousStep}+ onDeploy={deployAgent}+ isDeploying={isDeploying}+ />)}</div></div>diff --git a/components/SelectRepository/RepoSetup.tsx b/utils/repoSetup.tssimilarity index 80%rename from components/SelectRepository/RepoSetup.tsxrename to utils/repoSetup.tsindex 6657217ca..0abc4769e 100644--- a/components/SelectRepository/RepoSetup.tsx+++ b/utils/repoSetup.ts@@ -1,4 +1,4 @@-import { useRepositories } from 'hooks/useRepositories'+import type { useRepositories } from 'hooks/useRepositories'export interface RepoSetup {fullName: stringdiff --git a/utils/smolTemplates.ts b/utils/smolTemplates.tsnew file mode 100644index 000000000..787ddeed6--- /dev/null+++ b/utils/smolTemplates.ts@@ -0,0 +1,29 @@+export interface Template {+ title: string+ content: string+}++const templates: { [key: string]: Template } = {+ createReactApp: {+ title: 'React App',+ content: '# A starter react app\nA starter react app based on the latest standards.',+ },+ createLaravelApp: {+ title: 'Laravel App',+ content: '',+ },+ createNextApp: {+ title: 'Next.js App',+ content: '',+ },+ createRailsApp: {+ title: 'Rails App',+ content: '',+ },+ createDjangoApp: {+ title: 'Django App',+ content: '',+ },+}++export default templates