Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Fix output; Add request check tool [WIP]
Tomas Valenta437f578bb2ab
diff --git a/api-service/codegen/tools/playground/playground.py b/api-service/codegen/tools/playground/playground.pyindex 57ea58e7c..8eb75868e 100644--- a/api-service/codegen/tools/playground/playground.py+++ b/api-service/codegen/tools/playground/playground.py@@ -174,6 +174,7 @@ class NodeJSPlayground(Playground):env_vars=self.env_vars,)print(res)+ return resdef run_typescript_code(self, code: str, typecheck: bool = False):self.write_file(self.default_typescript_code_file, code)@@ -199,6 +200,7 @@ class NodeJSPlayground(Playground):request_cmd: str,port: float,):+print("CALLING", code)self.write_file(self.default_javascript_code_file, code)result = self.run_server_with_request(diff --git a/api-service/codegen/tools/playground/tools/code.py b/api-service/codegen/tools/playground/tools/code.pyindex 20a1aceed..52105f094 100644--- a/api-service/codegen/tools/playground/tools/code.py+++ b/api-service/codegen/tools/playground/tools/code.py@@ -23,7 +23,7 @@ def create_code_tools(playground: NodeJSPlayground, mock: MockRequestFactory):result = encode_command_output(output, only_errors=True)return result if len(result) > 0 else "All dependencies installed"- yield install_dependencies+ # yield install_dependencies# This tool is just for executing TypeScript without doing the request to server# @tool("RunTypeScriptCode")@@ -79,6 +79,7 @@ def create_code_tools(playground: NodeJSPlayground, mock: MockRequestFactory):# yield check_typescript_code_types+ last_javascript_code: str | None# This tool is just for executing JavaScript without doing the request to server@tool("RunJavaScriptCode")def run_javascript_code(code: str) -> str:@@ -86,12 +87,40 @@ def create_code_tools(playground: NodeJSPlayground, mock: MockRequestFactory):Run JavaScript code and return errors and output.Input should be a valid JavaScript code."""+ last_javascript_code = codeoutput = playground.run_javascript_code(extract_code(code))result = encode_command_output(output)return result if len(result) > 0 else "Code execution finished without error"yield run_javascript_code+ @tool("TryJavaScriptServer")+ def try_javascript_server(empty: str) -> str:+ """+ Make a request to check if the last JavaScript code is a server that can handle the request.+ """+ if last_javascript_code is None:+ return "No JavaScript code was previously run"++ mock_request_cmd = mock.terminal_command()++ port = 3000+ (+ request_output,+ server_output,+ ) = playground.run_javascript_server_code_with_request(+ code=last_javascript_code,+ request_cmd=mock_request_cmd,+ port=port,+ )++ request_result = encode_command_output(request_output)+ server_result = encode_command_output(server_output)++ return f"Request result:\n{request_result}\nCode execution result:\n{server_result}"++ # yield run_javascript_code+# @tool("RunJavaScriptCode")# def run_javascript_code(code: str) -> str:# """diff --git a/api-service/playground/src/sessions/processesController.ts b/api-service/playground/src/sessions/processesController.tsindex 25aced1f5..87818a4b3 100644--- a/api-service/playground/src/sessions/processesController.ts+++ b/api-service/playground/src/sessions/processesController.ts@@ -48,7 +48,6 @@ export class ProcessController extends Controller {if (wait) {await cachedProcess.process?.exited}-return cachedProcess.response}diff --git a/api-service/playground/src/sessions/session.ts b/api-service/playground/src/sessions/session.tsindex 74c3527b3..1719e8bb1 100644--- a/api-service/playground/src/sessions/session.ts+++ b/api-service/playground/src/sessions/session.ts@@ -103,7 +103,6 @@ export class CachedSession {}static findSession(id: string) {-const cachedSession = sessionCache.get(id) as CachedSessionif (!cachedSession) throw new Error('Session does not exist')return cachedSession