agentfs-sdk 0.3.1 → 0.4.0-pre.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/agentfs.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { DatabasePromise } from '@tursodatabase/database-common';
2
2
  import { KvStore } from './kvstore.js';
3
- import { Filesystem } from './filesystem.js';
3
+ import { AgentFS as Filesystem } from './filesystem/index.js';
4
4
  import { ToolCalls } from './toolcalls.js';
5
5
  /**
6
6
  * Configuration options for opening an AgentFS instance
@@ -0,0 +1,20 @@
1
+ /**
2
+ * POSIX-style error codes for filesystem operations.
3
+ */
4
+ export type FsErrorCode = 'ENOENT' | 'EEXIST' | 'EISDIR' | 'ENOTDIR' | 'ENOTEMPTY' | 'EPERM' | 'EINVAL' | 'ENOSYS';
5
+ /**
6
+ * Filesystem syscall names for error reporting.
7
+ * rm, scandir and copyFile are not actual syscall but used for convenience
8
+ */
9
+ export type FsSyscall = 'open' | 'stat' | 'mkdir' | 'rmdir' | 'rm' | 'unlink' | 'rename' | 'scandir' | 'copyfile' | 'access';
10
+ export interface ErrnoException extends Error {
11
+ code?: FsErrorCode;
12
+ syscall?: FsSyscall;
13
+ path?: string;
14
+ }
15
+ export declare function createFsError(params: {
16
+ code: FsErrorCode;
17
+ syscall: FsSyscall;
18
+ path?: string;
19
+ message?: string;
20
+ }): ErrnoException;
package/dist/errors.js ADDED
@@ -0,0 +1,13 @@
1
+ export function createFsError(params) {
2
+ const { code, syscall, path, message } = params;
3
+ const base = message ?? code;
4
+ const suffix = path !== undefined
5
+ ? ` '${path}'`
6
+ : '';
7
+ const err = new Error(`${code}: ${base}, ${syscall}${suffix}`);
8
+ err.code = code;
9
+ err.syscall = syscall;
10
+ if (path !== undefined)
11
+ err.path = path;
12
+ return err;
13
+ }
@@ -0,0 +1,56 @@
1
+ import type { DatabasePromise } from '@tursodatabase/database-common';
2
+ import { type Stats, type DirEntry, type FilesystemStats, type FileHandle, type FileSystem } from './interface.js';
3
+ /**
4
+ * A filesystem backed by SQLite, implementing the FileSystem interface.
5
+ */
6
+ export declare class AgentFS implements FileSystem {
7
+ private db;
8
+ private bufferCtor;
9
+ private rootIno;
10
+ private chunkSize;
11
+ private constructor();
12
+ static fromDatabase(db: DatabasePromise, b?: BufferConstructor): Promise<AgentFS>;
13
+ getChunkSize(): number;
14
+ private initialize;
15
+ private ensureRoot;
16
+ private normalizePath;
17
+ private splitPath;
18
+ private resolvePathOrThrow;
19
+ private resolvePath;
20
+ private resolveParent;
21
+ private createInode;
22
+ private createDentry;
23
+ private ensureParentDirs;
24
+ private getLinkCount;
25
+ private getInodeMode;
26
+ writeFile(path: string, content: string | Buffer, options?: BufferEncoding | {
27
+ encoding?: BufferEncoding;
28
+ }): Promise<void>;
29
+ private updateFileContent;
30
+ readFile(path: string): Promise<Buffer>;
31
+ readFile(path: string, encoding: BufferEncoding): Promise<string>;
32
+ readFile(path: string, options: {
33
+ encoding: BufferEncoding;
34
+ }): Promise<string>;
35
+ readdir(path: string): Promise<string[]>;
36
+ readdirPlus(path: string): Promise<DirEntry[]>;
37
+ stat(path: string): Promise<Stats>;
38
+ lstat(path: string): Promise<Stats>;
39
+ mkdir(path: string): Promise<void>;
40
+ rmdir(path: string): Promise<void>;
41
+ unlink(path: string): Promise<void>;
42
+ rm(path: string, options?: {
43
+ force?: boolean;
44
+ recursive?: boolean;
45
+ }): Promise<void>;
46
+ private rmDirContentsRecursive;
47
+ private removeDentryAndMaybeInode;
48
+ rename(oldPath: string, newPath: string): Promise<void>;
49
+ copyFile(src: string, dest: string): Promise<void>;
50
+ symlink(target: string, linkpath: string): Promise<void>;
51
+ readlink(path: string): Promise<string>;
52
+ access(path: string): Promise<void>;
53
+ statfs(): Promise<FilesystemStats>;
54
+ open(path: string): Promise<FileHandle>;
55
+ deleteFile(path: string): Promise<void>;
56
+ }