Skip to content

The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.

4.1 KB
Raw Blame
/*
 * Copyright 2025 Daytona Platforms Inc.
 * Modified by BoxLite AI, 2025-2026
 * SPDX-License-Identifier: AGPL-3.0
 */

import { ApiProperty, ApiPropertyOptional, ApiSchema } from '@nestjs/swagger'
import { NetworkInfoResponseDto } from '../../box/dto/network-info.dto'

@ApiSchema({ name: 'Box' })
export class BoxResponseDto {
  @ApiProperty({
    description: 'The public 12-character Box ID shown to users and SDK clients',
    example: 'aB3cD4eF5gH6',
  })
  box_id: string

  @ApiPropertyOptional({
    description: 'User-provided box name',
    example: 'notebook-worker',
  })
  name?: string

  @ApiProperty({
    description: 'Box runtime status',
    example: 'running',
  })
  status: string

  @ApiProperty({
    description: 'Creation timestamp',
    example: '2026-06-04T12:00:00.000Z',
  })
  created_at: string

  @ApiProperty({
    description: 'Last update timestamp',
    example: '2026-06-04T12:05:00.000Z',
  })
  updated_at: string

  @ApiPropertyOptional({
    description: 'Timestamp of the last recorded activity on the box; absent when none was recorded',
    example: '2026-06-04T12:04:30.000Z',
  })
  last_activity_at?: string

  @ApiPropertyOptional({
    description: 'Runtime process ID when available',
    example: 12345,
  })
  pid?: number

  @ApiProperty({
    description: 'Approved image used for the box',
    example: 'boxlite/base',
  })
  image: string

  @ApiProperty({
    description: 'Allocated CPU count',
    example: 2,
  })
  cpus: number

  @ApiProperty({
    description: 'Allocated memory in MiB',
    example: 4096,
  })
  memory_mib: number

  @ApiPropertyOptional({
    description: 'Persisted guest privilege mode; absent means unknown, not false',
  })
  privileged?: boolean

  @ApiProperty({
    description: 'Labels attached to the box',
    type: 'object',
    additionalProperties: { type: 'string' },
    example: { 'boxlite.io/public': 'true' },
  })
  labels: Record<string, string>

  @ApiProperty({
    description: 'Idle time in seconds before AutoStop; 0 disables AutoStop',
    example: 900,
  })
  auto_stop: number

  @ApiProperty({
    description: 'Stopped time in seconds before AutoDelete; 0 disables AutoDelete',
    example: 604800,
  })
  auto_delete: number

  @ApiProperty({
    description: 'Whether the box should be automatically resumed on proxy access',
    example: true,
  })
  auto_resume: boolean

  @ApiPropertyOptional({
    description:
      "How the box's main command ended, present once the box has stopped and the runtime " +
      'recorded it. A command that exited on its own reports its own code; one ended by a signal ' +
      'reports `128 + n`. Stopping a box signals that command, so a stop is recorded here too. ' +
      'Absent while the box is running, and when nothing was recorded. `0` is a ' +
      'real value, so a client must tell the missing field from a zero one. Only reading a single ' +
      'box carries it: this schema is shared with the box list and with every other reply built ' +
      'from it, which leave it out whether or not one was recorded.',
    example: 137,
  })
  exit_code?: number

  // Optional to match openapi/box.openapi.yaml, where older servers omit it.
  @ApiPropertyOptional({
    description: 'The effective network policy in both directions',
    type: NetworkInfoResponseDto,
  })
  network?: NetworkInfoResponseDto
}

@ApiSchema({ name: 'ListBoxesResponse' })
export class ListBoxesResponseDto {
  @ApiProperty({ type: [BoxResponseDto] })
  boxes: BoxResponseDto[]

  @ApiPropertyOptional({
    description: 'Token for the next page when pagination is available',
    example: 'eyJwYWdlIjoyfQ',
  })
  next_page_token?: string
}

class ErrorDetailDto {
  @ApiProperty({
    description: 'Human-readable error message',
    example: 'Box not found',
  })
  message: string

  @ApiProperty({
    description: 'Machine-readable error type',
    example: 'not_found',
  })
  type: string

  @ApiProperty({
    description: 'HTTP status code',
    example: 404,
  })
  code: number
}

@ApiSchema({ name: 'BoxLiteRestError' })
export class ErrorResponseDto {
  @ApiProperty({ type: ErrorDetailDto })
  error: ErrorDetailDto
}