Skip to content

feat(backend): add application DTO layer for sandbox views - #171

Draft
Simpleyyt wants to merge 5 commits into
mainfrom
cursor/application-dto-layer-5b74
Draft

feat(backend): add application DTO layer for sandbox views#171
Simpleyyt wants to merge 5 commits into
mainfrom
cursor/application-dto-layer-5b74

Conversation

@Simpleyyt

Copy link
Copy Markdown
Owner

Summary

Adds an Application DTO layer and fixes the dependency violation where AgentService returned interfaces/schemas types directly.

Changes

  • application/dto/sandbox.pyShellViewDto, FileViewDto, ConsoleRecordDto with from_tool_data() factories for sandbox ToolResult payloads
  • interfaces/mappers/sandbox_mapper.py — maps Application DTOs → API *Response schemas
  • AgentServiceshell_view / file_view now return DTOs (no interfaces imports)
  • session_routes.py — uses mapper before returning APIResponse

Dependency flow (after)

interfaces (routes) → application (AgentService + DTO) → domain
interfaces (mappers)  → application DTO → interfaces schemas

Follow-ups (not in this PR)

  • Move FileInfoResponse.from_file_info service-locator logic into a mapper
  • Add application/errors domain exception mapping
  • Extend DTOs for other use cases if needed
Open in Web Open in Cursor 

cursoragent and others added 5 commits July 5, 2026 13:26
Introduce application/dto for shell and file view use-case outputs,
interfaces/mappers to convert DTOs to API schemas, and remove the
Application -> Interfaces dependency in AgentService.

Co-authored-by: Simpleyyt <simpleyyt@gmail.com>
Replace manual field extraction with Pydantic model_validate so nested
console records are coerced automatically, ignore extra keys, and raise
a clear error on empty sandbox payloads.

Co-authored-by: Simpleyyt <simpleyyt@gmail.com>
Replace from_tool_data(Mapping[str, Any]) with from_result() that takes
the strongly-typed domain ShellViewResult / FileReadResult. The dict->
model boundary now lives in the domain models (sandbox ACL); DTOs only
project domain value objects, removing the stringly-typed dict signature.

Co-authored-by: Simpleyyt <simpleyyt@gmail.com>
Cover domain wire->DTO->API mapper chain and mocked shell_view/file_view
use cases including sandbox failure handling.

Co-authored-by: Simpleyyt <simpleyyt@gmail.com>
Exercise the full wire->domain->DTO->API chain against a running dev
stack (backend :8000, sandbox :8080). Mark with pytest integration.

Co-authored-by: Simpleyyt <simpleyyt@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants