Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Fix logs response handling
Tomas Valenta8f784c210fb1
diff --git a/packages/cli/src/commands/sandbox/logs.ts b/packages/cli/src/commands/sandbox/logs.tsindex 6a12dcda6..836096252 100644--- a/packages/cli/src/commands/sandbox/logs.ts+++ b/packages/cli/src/commands/sandbox/logs.ts@@ -3,7 +3,7 @@ import * as e2b from 'e2b'import * as util from 'util'import { ensureAPIKey } from 'src/api'-import { asBold, asTimestamp, asPrimary, asDim } from 'src/utils/format'+import { asBold, asTimestamp, asPrimary } from 'src/utils/format'import { listSandboxes } from './list'const getSandboxLogs = e2b.withAPIKey(@@ -45,16 +45,15 @@ export const logsCommand = new commander.Command('logs')printSandboxInfo({isRunning: !!sandbox,- envID: logs.envID,- sandboxID: logs.sandboxID,+ sandboxID: sandboxID,})}- for (const log of logs.logs) {+ for (const log of logs) {printLog(log.timestamp, log.line)}- const lastLog = logs.logs[logs.logs.length - 1]+ const lastLog = logs[logs.length - 1]if (lastLog) {start = new Date(lastLog.timestamp).getTime()}@@ -65,19 +64,17 @@ export const logsCommand = new commander.Command('logs')}})-function printSandboxInfo({ envID, sandboxID, isRunning }: {- envID: string,+function printSandboxInfo({ sandboxID, isRunning }: {sandboxID: string,isRunning: boolean,}) {- process.stdout.write(`Logs for ${asBold(isRunning ? 'running' : 'closed')} sandbox ${asPrimary(sandboxID)} created from template ${asDim(envID)}:\n\n`)+ process.stdout.write(`Logs for ${asBold(isRunning ? 'running' : 'closed')} sandbox ${asPrimary(sandboxID)}:\n\n`)}function printLog(timestamp: string, line: string) {const log = JSON.parse(line)delete log['TraceID']- delete log['envID']delete log['instanceID']delete log['sandboxID']delete log['source_type']@@ -93,7 +90,7 @@ export async function listSandboxLogs({apiKey,sandboxID,start,-}: { apiKey: string, sandboxID: string, start?: number }): Promise<e2b.components['schemas']['SandboxLogs']> {+}: { apiKey: string, sandboxID: string, start?: number }): Promise<e2b.components['schemas']['SandboxLog'][]> {const response = await getSandboxLogs(apiKey, { sandboxID, start })- return response.data+ return response.data.logs}diff --git a/packages/js-sdk/src/api/schema.gen.ts b/packages/js-sdk/src/api/schema.gen.tsindex 3ba2d2fc1..747c1d6a0 100644--- a/packages/js-sdk/src/api/schema.gen.ts+++ b/packages/js-sdk/src/api/schema.gen.ts@@ -263,21 +263,19 @@ export interface paths {export interface components {schemas: {SandboxMetadata: { [key: string]: string };+ /** @description Log entry with timestamp and line */+ SandboxLog: {+ /**+ * Format: date-time+ * @description Timestamp of the log entry+ */+ timestamp: string;+ /** @description Log line content */+ line: string;+ };SandboxLogs: {- /** @description Logs of the sandbox with timestamp and line */- logs: {- /**- * Format: date-time- * @description Timestamp of the log entry- */- timestamp: string;- /** @description Log line content */- line: string;- }[];- /** @description ID of the sandbox */- sandboxID: string;- /** @description ID of the environment */- envID: string;+ /** @description Logs of the sandbox */+ logs: components["schemas"]["SandboxLog"][];};Sandbox: {/** @description Identifier of the template from which is the sandbox created */diff --git a/spec/openapi.yml b/spec/openapi.ymlindex eb85a5ead..f6ef14188 100644--- a/spec/openapi.yml+++ b/spec/openapi.yml@@ -70,34 +70,30 @@ components:type: stringdescription: Metadata of the sandbox+ SandboxLog:+ description: Log entry with timestamp and line+ required:+ - timestamp+ - line+ properties:+ timestamp:+ type: string+ format: date-time+ description: Timestamp of the log entry+ line:+ type: string+ description: Log line content+SandboxLogs:required:- logs- - sandboxID- - envIDproperties:logs:+ description: Logs of the sandboxtype: arrayitems:- type: object- required:- - timestamp- - line- properties:- timestamp:- type: string- format: date-time- description: Timestamp of the log entry- line:- type: string- description: Log line content- description: Logs of the sandbox with timestamp and line- sandboxID:- type: string- description: ID of the sandbox- envID:- type: string- description: ID of the environment+ $ref: "#/components/schemas/SandboxLog"+Sandbox:required:- templateID