Skip to content

Conversation

@psrvere
Copy link
Contributor

@psrvere psrvere commented Dec 18, 2025

Closes #76

  • added 6 new APIs - mkdir, rm, rmdir, rename, copyFile and access
  • renamed deleteFile API to unlink for consistency with node API. Keeping deleteFile API for backward compatibility
  • improved error checking across all existing APIs
  • added guards.ts file to keep all assertion functions in one place
  • minor refactoring in filesystem.ts file
  • added a typescript config file in tests folder to remove linting errors

Following table summarizes changes I have made and existing parity gaps with node APIs:

Node AgentFS Status What's added Parity Gaps
readFile(path, options?) readFile(path, options?) error handling abort signal, file open flag
writeFile(path, data, options?) writeFile(path, content, options?) encoding and error handling abort signal, file open flag, permission mode, auto-creates parent dirs (Node would ENOENT)
readdir(path, options?) readdir(path) error handling encoding, withFileTypes and recursive options
unlink(path) unlink(path) (alias: deleteFile(path)) error handling NA
stat(path, options?) stat(path) NA biginit option, more fields in return value
mkdir(path, options?) mkdir(path) added recursive and mode options
rm(path, options) rm(path, options) added rm with force + recursive options, error handling missing other options (maxRetries, retryDelay)
rmdir(path, options?) rmdir(path) added options.recursive is deprecated
rename(oldPath, newPath) rename(oldPath, newPath) added NA
copyFile(src, dest, mode?) copyFile(src, dest) added copyFile flags (COPYFILE_EXCL, etc) not supported
access(path, mode?) access(path) added mode flags
appendFile(path, data, options?) Not implemented
open(path, flags, mode?) Not implemented
truncate(path, len?) Not implemented

I decided to skip appendFile, open and truncate APIs as it felt like an overkill for current usage. I have left it here for documentation reasons. Please let me know if you disagree.

@psrvere psrvere changed the title Improved TypeScript SDK API Coverage Improve TypeScript SDK API Coverage Dec 18, 2025
@psrvere psrvere marked this pull request as ready for review December 19, 2025 07:28
@penberg penberg changed the title Improve TypeScript SDK API Coverage TypeScript SDK API improvements Dec 19, 2025
}

export function createFsError(params: {
code: string;
Copy link

@jussisaurio jussisaurio Dec 20, 2025

Choose a reason for hiding this comment

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

I think our lives would be easier if these were string unions like type FsErrorCode = 'ENOENT' | 'EISDIR' | 'EINVAL' ..., same for syscall. TypeScript type system is really powerful, let's use it

Choose a reason for hiding this comment

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

btw you can just tell claude to do this and it'll do it in 1 minute

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jussisaurio - that makes sense. I have added the type definitions.

- added two new APIs - mkdir and rm
- renamed deleteFile API to unlink for consistency with node APIs. Keeping deleteFile API for backward compatability
- added better error checking across all exisitng APIs
- added guards.ts file to keep all assertion functions in one place
- minor refactoring in filesystem.ts file

Signed-off-by: Prateek Singh Rathore <[email protected]>
Signed-off-by: Prateek Singh Rathore <[email protected]>
- used copyfile as syscall as node API uses it
- updated metadata in the copy process
- if destination exists, it is overwritten

Signed-off-by: Prateek Singh Rathore <[email protected]>
It only checks if path exists and doesn't check for permissions.

Signed-off-by: Prateek Singh Rathore <[email protected]>
@psrvere psrvere force-pushed the improve-api-coverage branch from abace67 to 3acca97 Compare December 20, 2025 09:06
Signed-off-by: Prateek Singh Rathore <[email protected]>
@penberg penberg merged commit 0185dc1 into tursodatabase:main Dec 20, 2025
33 checks passed
penberg added a commit that referenced this pull request Dec 29, 2025
Adjust Python bindings with new changes

- #101
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.

Improve TypeScript SDK API coverage

3 participants