Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Improve deployment secret handling; Update API client

Tomas Valentad75af4545a43
diff --git a/api-client/api/schema.gen.ts b/api-client/api/schema.gen.ts
index 7b70d4c20..891186e94 100644
--- a/api-client/api/schema.gen.ts
+++ b/api-client/api/schema.gen.ts
@@ -6,8 +6,6 @@
export interface paths {
"/deployments": {
- /** List Deployments */
- get: operations["list_deployments_deployments_get"];
/** Create Agent Deployment */
put: operations["create_agent_deployment_deployments_put"];
};
@@ -17,17 +15,13 @@ export interface paths {
/** Delete Agent Deployment */
delete: operations["delete_agent_deployment_deployments__id__delete"];
};
- "/deployments/{id}/interaction_requests": {
- /** Get Agent Intereaction Requests */
- get: operations["get_agent_intereaction_requests_deployments__id__interaction_requests_get"];
- };
"/deployments/{id}/interactions": {
/** Interact With Agent Deployment */
post: operations["interact_with_agent_deployment_deployments__id__interactions_post"];
};
- "/deployments/{id}/logs": {
- /** Get Agent Deployment Status */
- get: operations["get_agent_deployment_status_deployments__id__logs_get"];
+ "/health": {
+ /** Health */
+ get: operations["health_health_get"];
};
}
@@ -48,6 +42,8 @@ export interface components {
CreateDeploymentBody: {
/** Config */
config?: Record<string, never>;
+ /** Secrets */
+ secrets?: Record<string, never>;
};
/** HTTPValidationError */
HTTPValidationError: {
@@ -75,17 +71,6 @@ export type external = Record<string, never>;
export interface operations {
- /** List Deployments */
- list_deployments_deployments_get: {
- responses: {
- /** @description Successful Response */
- 200: {
- content: {
- "application/json": Record<string, never>;
- };
- };
- };
- };
/** Create Agent Deployment */
create_agent_deployment_deployments_put: {
parameters: {
@@ -153,28 +138,6 @@ export interface operations {
};
};
};
- /** Get Agent Intereaction Requests */
- get_agent_intereaction_requests_deployments__id__interaction_requests_get: {
- parameters: {
- path: {
- id: string;
- };
- };
- responses: {
- /** @description Successful Response */
- 200: {
- content: {
- "application/json": Record<string, never>;
- };
- };
- /** @description Validation Error */
- 422: {
- content: {
- "application/json": components["schemas"]["HTTPValidationError"];
- };
- };
- };
- };
/** Interact With Agent Deployment */
interact_with_agent_deployment_deployments__id__interactions_post: {
parameters: {
@@ -202,13 +165,8 @@ export interface operations {
};
};
};
- /** Get Agent Deployment Status */
- get_agent_deployment_status_deployments__id__logs_get: {
- parameters: {
- path: {
- id: string;
- };
- };
+ /** Health */
+ health_health_get: {
responses: {
/** @description Successful Response */
200: {
@@ -216,12 +174,6 @@ export interface operations {
"application/json": Record<string, never>;
};
};
- /** @description Validation Error */
- 422: {
- content: {
- "application/json": components["schemas"]["HTTPValidationError"];
- };
- };
};
};
}
diff --git a/api-service/app.py b/api-service/app.py
index 852a3ac9b..bc57210fb 100644
--- a/api-service/app.py
+++ b/api-service/app.py
@@ -48,6 +48,7 @@ async def health():
class CreateDeploymentBody(BaseModel):
config: Any
+ secrets: Any
@app.put("/deployments")
@@ -60,13 +61,22 @@ async def create_agent_deployment(
db_deployment = await db.get_deployment(project_id)
if db_deployment:
- secrets= json.loads(db_deployment["decrypted_secrets"]) if db_deployment.get('decrypted_secrets', None) else {}
+ secrets = (
+ json.loads(db_deployment["decrypted_secrets"])
+ if db_deployment.get("decrypted_secrets", None)
+ else {}
+ )
+ print("secrets", secrets)
deployment = await deployment_manager.update_deployment(
db_deployment["id"],
project_id,
{
+ **db_deployment["config"],
**body.config,
+ },
+ {
**secrets,
+ **body.secrets,
},
)
current_span = trace.get_current_span()
@@ -92,6 +102,7 @@ async def create_agent_deployment(
id,
project_id,
body.config,
+ body.secrets,
)
current_span = trace.get_current_span()
current_span.set_attributes(
@@ -159,6 +170,9 @@ async def interact_with_agent_deployment(
db_deployment["id"],
db_deployment["project_id"],
db_deployment["config"],
+ json.loads(db_deployment["secrets"])
+ if db_deployment["secrets"]
+ else {},
)
else:
raise HTTPException(status_code=404, detail="Deployment not found")
diff --git a/api-service/database/database.py b/api-service/database/database.py
index 9c2621584..81e730142 100644
--- a/api-service/database/database.py
+++ b/api-service/database/database.py
@@ -4,7 +4,7 @@ from typing import Any, List
from database.client import Client
from session.env import EnvVar
-TABLE_DECRYPTED_DEPLOYMENTS = "deployments"
+TABLE_DECRYPTED_DEPLOYMENTS = "decrypted_deployments"
TABLE_DEPLOYMENTS = "deployments"
TABLE_LOGS = "log_files"
TABLE_PROJECTS = "projects"
@@ -79,6 +79,7 @@ class Database:
id: str,
project_id: str,
config: Any,
+ secrets: Any,
) -> None:
await self.client.table(TABLE_DEPLOYMENTS).upsert(
{
@@ -86,6 +87,7 @@ class Database:
"enabled": True,
"project_id": project_id,
"config": config,
+ "secrets": json.dumps(secrets),
},
on_conflict="id",
).execute()
diff --git a/api-service/deployment/in_memory.py b/api-service/deployment/in_memory.py
index c12c705ef..2ba372437 100644
--- a/api-service/deployment/in_memory.py
+++ b/api-service/deployment/in_memory.py
@@ -46,16 +46,20 @@ class InMemoryDeploymentManager(AgentDeploymentManager):
id: str,
project_id: str,
config: Any,
+ secrets: Any,
):
print("Creating deployment", config)
deployment = await AgentDeployment.from_factory(
id,
get_agent_factory_from_template(config["templateID"]),
project_id,
- config,
+ {
+ **config,
+ **secrets,
+ },
)
try:
- await db.create_deployment(deployment.id, project_id, config)
+ await db.create_deployment(deployment.id, project_id, config, secrets)
except:
await deployment.agent.stop()
raise
@@ -68,6 +72,7 @@ class InMemoryDeploymentManager(AgentDeploymentManager):
id: str,
project_id: str,
config: Any,
+ secrets: Any,
):
print(">>>> Updating deployment", id, config)
try:
@@ -79,6 +84,7 @@ class InMemoryDeploymentManager(AgentDeploymentManager):
id,
project_id,
config,
+ secrets,
)
async def remove_deployment(self, id: str):
diff --git a/api-service/openapi.json b/api-service/openapi.json
index 61bf6d0dc..90790f2a5 100644
--- a/api-service/openapi.json
+++ b/api-service/openapi.json
@@ -5,10 +5,10 @@
"version": "0.1.0"
},
"paths": {
- "/deployments": {
+ "/health": {
"get": {
- "summary": "List Deployments",
- "operationId": "list_deployments_deployments_get",
+ "summary": "Health",
+ "operationId": "health_health_get",
"responses": {
"200": {
"description": "Successful Response",
@@ -18,13 +18,10 @@
}
}
}
- },
- "security": [
- {
- "OAuth2PasswordBearer": []
- }
- ]
- },
+ }
+ }
+ },
+ "/deployments": {
"put": {
"summary": "Create Agent Deployment",
"operationId": "create_agent_deployment_deployments_put",
@@ -204,90 +201,6 @@
}
]
}
- },
- "/deployments/{id}/interaction_requests": {
- "get": {
- "summary": "Get Agent Intereaction Requests",
- "operationId": "get_agent_intereaction_requests_deployments__id__interaction_requests_get",
- "parameters": [
- {
- "required": true,
- "schema": {
- "title": "Id",
- "type": "string"
- },
- "name": "id",
- "in": "path"
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {}
- }
- }
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- }
- }
- },
- "security": [
- {
- "OAuth2PasswordBearer": []
- }
- ]
- }
- },
- "/deployments/{id}/logs": {
- "get": {
- "summary": "Get Agent Deployment Status",
- "operationId": "get_agent_deployment_status_deployments__id__logs_get",
- "parameters": [
- {
- "required": true,
- "schema": {
- "title": "Id",
- "type": "string"
- },
- "name": "id",
- "in": "path"
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {}
- }
- }
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- }
- }
- },
- "security": [
- {
- "OAuth2PasswordBearer": []
- }
- ]
- }
}
},
"components": {
@@ -318,6 +231,9 @@
"properties": {
"config": {
"title": "Config"
+ },
+ "secrets": {
+ "title": "Secrets"
}
}
},
diff --git a/pages/api/agent/index.ts b/pages/api/agent/index.ts
index baa22702f..fc32127d4 100644
--- a/pages/api/agent/index.ts
+++ b/pages/api/agent/index.ts
@@ -189,7 +189,8 @@ async function postAgent(req: NextApiRequest, res: NextApiResponse) {
await createAgentDeployment({
project_id: project.id,
- config: { templateID, openAIKey } as any,
+ config: { templateID } as any,
+ secrets: { openAIKey } as any,
})
const deployment = project.deployments[0]