Skip to content

feat(daemon,sdk): add depth-aware recursive file listing#5030

Open
MDzaja wants to merge 1 commit into
mainfrom
feat/fs-list-depth
Open

feat(daemon,sdk): add depth-aware recursive file listing#5030
MDzaja wants to merge 1 commit into
mainfrom
feat/fs-list-depth

Conversation

@MDzaja

@MDzaja MDzaja commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

Adds an optional depth parameter to GET /files (and all SDK listFiles / list_files wrappers) for recursive directory listing. When omitted, behavior is identical to the current shallow listing.

Changes

Daemon (apps/daemon/pkg/toolbox/fs/)

  • New depth query parameter on GET /files (integer, default 1, must be ≥ 1)
  • depth=1 preserves the original os.ReadDir code path (no behavioral change for default case)
  • depth > 1 uses filepath.WalkDir with depth-bounded descent, returning a flat list
  • New path field on FileInfo (full entry path, omitempty for backward compat)
  • Unreadable subtrees are skipped (partial results), symlinks are listed but not followed
  • Uses ClientRejectsUnknownResponseFields to omit the new path field for older Go SDK clients that reject unknown JSON fields

SDKs (all 5 languages)

  • listFiles(path, depth?) / list_files(path, depth=None) with client-side validation (depth must be at least 1)
  • TypeScript: listFiles(path, { depth?: number })
  • Python: list_files(path, depth: int | None = None) (sync + async)
  • Go: ListFiles(ctx, path, options.WithDepth(n))
  • Ruby: list_files(path, depth: nil)
  • Java: listFiles(path) + listFiles(path, Integer depth) overload
  • Go SDK: FileInfo.Path field added to types + mapped from generated client

Generated clients — all 6 toolbox API clients regenerated with the new depth param and path model field.

Behavior

Request Result
GET /files?path=/tmp/x Shallow listing (unchanged from before)
GET /files?path=/tmp/x&depth=1 Identical to above
GET /files?path=/tmp/x&depth=3 Flat list including entries up to 3 levels deep
GET /files?path=/tmp/x&depth=0 400 Bad Request
Nonexistent path 404
Unreadable subdirectory mid-walk Skipped, rest of tree returned (200)
Symlink to directory Listed once, never descended into (no cycle risk)
Dangling symlink Omitted (stat fails)

Backward Compatibility

  • Default behavior unchanged — depth is optional, defaults to 1
  • path field uses omitempty — absent when empty, old clients ignore it
  • Daemon uses ClientRejectsUnknownResponseFields to strip path for Go SDK clients below v0.188.0 (whose generated client rejects unknown JSON fields)
  • Verified against published 0.185.0 SDKs (Python, TypeScript, Ruby, Go) on preprod

Summary by cubic

Adds depth-aware recursive file listing to GET /files and all SDK listFiles methods. Default stays shallow; responses now include a path field with the full entry path.

  • New Features
    • API: new depth query (default 1, must be ≥1). depth=1 uses the original shallow path; >1 returns a flat list up to N levels. Symlinks are listed but not followed; unreadable subtrees are skipped; invalid depth returns 400. Recursive listing handles a symlinked root by resolving it for walking while reporting path under the requested root.
    • Response: FileInfo.path added (full path). Older Go SDKs have this field stripped automatically for compatibility.
    • SDKs:
      • TypeScript: listFiles(path, { depth?: number }) with client-side validation.
      • Python: list_files(path, depth: int | None = None) (sync/async) with validation.
      • Go: ListFiles(ctx, path, options.WithDepth(n)).
      • Ruby: list_files(path, depth: nil) with validation.
      • Java: listFiles(path) and listFiles(path, Integer depth) with validation.
    • Regenerated toolbox API clients (Go/TS/Java/Python/Ruby) and updated docs across all languages.

Written for commit 2ce4ac6. Summary will update on new commits.

Review in cubic

@nx-cloud

nx-cloud Bot commented Jun 12, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 2ce4ac6

Command Status Duration Result
nx e2e:cleanup daytona-e2e ✅ Succeeded 1s View ↗
nx run sdk-typescript:test:runtime ✅ Succeeded 2m 44s View ↗
nx run-many --target=test:e2e --all --nxBail=true ✅ Succeeded 6m 27s View ↗
nx e2e daytona-e2e ✅ Succeeded 57s View ↗
nx run-many --target=build --projects=api,runne... ✅ Succeeded 52s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-12 14:48:52 UTC

@MDzaja MDzaja force-pushed the feat/fs-list-depth branch from 28e461e to 85e81ac Compare June 12, 2026 10:40

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found and verified against the latest diff

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread apps/docs/src/content/docs/en/ruby-sdk/file-system.mdx Outdated
Comment thread apps/daemon/pkg/toolbox/fs/list_files.go Outdated
Comment thread libs/sdk-typescript/src/FileSystem.ts Outdated
Comment thread apps/docs/src/content/docs/en/typescript-sdk/file-system.mdx
Comment thread libs/sdk-ruby/lib/daytona/file_system.rb Outdated
Signed-off-by: MDzaja <mirkodzaja0@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.

1 participant