Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Fix deploy import; Improve logs [WIP]

Tomas Valenta459f163d46f1
diff --git a/api-service/playground/src/deployments/packaging.ts b/api-service/playground/src/deployments/packaging.ts
index ceab439c9..a2504eb07 100644
--- a/api-service/playground/src/deployments/packaging.ts
+++ b/api-service/playground/src/deployments/packaging.ts
@@ -40,7 +40,7 @@ function addAWSLambdaHandlers(code: string) {
const isECMA = !code.includes('require')
if (isECMA) {
- code = 'import serverless from "serverless-http;"\n' + code
+ code = 'import serverless from "serverless-http";\n' + code
code = code + "\nexport const handler = serverless(app);"
} else {
code = "const serverless = require('serverless-http');\n" + code
diff --git a/components/Editor/ConnectionLine.tsx b/components/Editor/ConnectionLine.tsx
index 302e80a74..7f3545c92 100644
--- a/components/Editor/ConnectionLine.tsx
+++ b/components/Editor/ConnectionLine.tsx
@@ -4,7 +4,7 @@ export interface Props {
function ConnectionLine({ className }: Props) {
return (
- <div className={`${className} border-l my-2 rounded border-slate-200`} />
+ <div className={`${className} border-l my-2 border-slate-200`} />
)
}
diff --git a/components/Editor/RightSidebar/Logs/LogEntry.tsx b/components/Editor/RightSidebar/Logs/LogEntry.tsx
new file mode 100644
index 000000000..e988fc88c
--- /dev/null
+++ b/components/Editor/RightSidebar/Logs/LogEntry.tsx
@@ -0,0 +1,82 @@
+import { Log } from 'db/types'
+import { Code2, Package, TerminalSquare, Wrench } from 'lucide-react'
+import { ReactMarkdown } from 'react-markdown/lib/react-markdown'
+
+function getToolIcon(toolName: string) {
+ switch (toolName) {
+ case 'InstallNPMDependencies':
+ return <Package size="16px" />
+ case 'RunJavaScriptCode':
+ return <Code2 size="16px" />
+ case 'CurlJavaScriptServer':
+ return <TerminalSquare size="16px" />
+ default:
+ return <Wrench size="16px" />
+ }
+}
+
+export interface Props {
+ log: Log
+}
+
+function LogEntry({ log }: Props) {
+ return (
+ <div className="
+ rounded-lg
+ p-3
+ border
+ border-slate
+ ">
+ {log.type === 'thought' &&
+ <div className="
+ italic
+ text-slate-400
+ ">
+ <ReactMarkdown>
+ {log.content}
+ </ReactMarkdown>
+ </div>
+ }
+ {log.type === 'tool' &&
+ <>
+ <div className="
+ flex
+ items-center
+ space-x-2
+ ">
+ {getToolIcon(log.name)}
+ <div className="font-medium">
+ {log.name}
+ </div>
+ </div>
+ {log.input.trim() &&
+ <div className="
+ border-t
+ mt-2
+ pt-2
+ "
+ >
+ <ReactMarkdown>
+ {'```' + log.input + '```'}
+ </ReactMarkdown>
+ </div>
+ }
+ {log.output?.trim() &&
+ <div className="
+ border-t
+ mt-2
+ pt-2
+ "
+ >
+ <ReactMarkdown>
+ {log.output}
+ </ReactMarkdown>
+ </div>
+ }
+ </>
+ }
+ </div>
+ )
+}
+
+export default LogEntry
diff --git a/components/Editor/RightSidebar/Logs.tsx b/components/Editor/RightSidebar/Logs/index.tsx
similarity index 79%
rename from components/Editor/RightSidebar/Logs.tsx
rename to components/Editor/RightSidebar/Logs/index.tsx
index dc0a636bc..7920dc68c 100644
--- a/components/Editor/RightSidebar/Logs.tsx
+++ b/components/Editor/RightSidebar/Logs/index.tsx
@@ -1,4 +1,5 @@
import {
+ Fragment,
useEffect,
useState,
} from 'react'
@@ -9,6 +10,8 @@ import Text from 'components/Text'
import { useTabs } from 'components/Tabs/useTabs'
import Tabs from 'components/Tabs'
import { Log } from 'db/types'
+import LogEntry from './LogEntry'
+import ConnectionLine from 'components/Editor/ConnectionLine'
export interface Props {
logs?: Log[]
@@ -54,6 +57,7 @@ function Logs({
justify-between
border-b
py-2
+ pr-4
">
<Text
text="Logs"
@@ -83,19 +87,20 @@ function Logs({
tracking-wide
font-sans
whitespace-pre-wrap
- space-y-4
p-4
">
- {selectedTab === 0 && (
- <>
- {logs?.map((l, i) =>
- <>
- {l.type === 'thought' && <div key={l.id}>{l.content}</div>}
- {l.type === 'tool' && !l.output && <div key={l.id}>{l.name}</div>}
- {l.type === 'tool' && l.output && <div key={l.id}>{l.name}{': '}{l.output}</div>}
- </>
- )}
- </>
+ {selectedTab === 0 && logs?.map((l, i, a) =>
+ <Fragment key={i}>
+ <LogEntry
+ log={l}
+ key={i}
+ />
+ {i < a.length - 1 &&
+ <div className="flex items-center flex-col">
+ <ConnectionLine className="h-4" />
+ </div>
+ }
+ </Fragment>
)}
{selectedTab === 1 && (
<>
diff --git a/components/Tabs/index.tsx b/components/Tabs/index.tsx
index 70a730894..1c1b18595 100644
--- a/components/Tabs/index.tsx
+++ b/components/Tabs/index.tsx
@@ -108,8 +108,7 @@ function Tab({
<button
key={i}
className={clsx(
- `text-sm
- relative
+ `relative
rounded-md
flex
items-center