@aigne/afs 1.3.0 → 1.4.0-beta.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/CHANGELOG.md +106 -0
- package/lib/cjs/afs.d.ts +25 -28
- package/lib/cjs/afs.js +210 -43
- package/lib/cjs/error.d.ts +13 -0
- package/lib/cjs/error.js +25 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/type.d.ts +189 -38
- package/lib/cjs/type.js +23 -0
- package/lib/dts/afs.d.ts +25 -28
- package/lib/dts/error.d.ts +13 -0
- package/lib/dts/index.d.ts +1 -0
- package/lib/dts/type.d.ts +189 -38
- package/lib/esm/afs.d.ts +25 -28
- package/lib/esm/afs.js +210 -43
- package/lib/esm/error.d.ts +13 -0
- package/lib/esm/error.js +20 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/type.d.ts +189 -38
- package/lib/esm/type.js +22 -1
- package/package.json +6 -2
package/lib/esm/type.d.ts
CHANGED
|
@@ -1,71 +1,180 @@
|
|
|
1
1
|
import type { Emitter } from "strict-event-emitter";
|
|
2
|
-
|
|
2
|
+
import { type ZodType, z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Access mode for AFS modules and root.
|
|
5
|
+
* - "readonly": Only read operations are allowed (list, read, search)
|
|
6
|
+
* - "readwrite": All operations are allowed
|
|
7
|
+
*/
|
|
8
|
+
export type AFSAccessMode = "readonly" | "readwrite";
|
|
9
|
+
/**
|
|
10
|
+
* Zod schema for access mode validation.
|
|
11
|
+
* Can be reused across modules that support access mode configuration.
|
|
12
|
+
*/
|
|
13
|
+
export declare const accessModeSchema: z.ZodOptional<z.ZodEnum<["readonly", "readwrite"]>>;
|
|
14
|
+
export interface AFSOperationOptions {
|
|
15
|
+
context?: any;
|
|
16
|
+
}
|
|
17
|
+
export interface AFSListOptions extends AFSOperationOptions {
|
|
3
18
|
filter?: {
|
|
19
|
+
agentId?: string;
|
|
4
20
|
userId?: string;
|
|
5
21
|
sessionId?: string;
|
|
22
|
+
before?: string;
|
|
23
|
+
after?: string;
|
|
6
24
|
};
|
|
7
|
-
recursive?: boolean;
|
|
8
25
|
maxDepth?: number;
|
|
9
26
|
limit?: number;
|
|
10
27
|
orderBy?: [string, "asc" | "desc"][];
|
|
28
|
+
maxChildren?: number;
|
|
29
|
+
onOverflow?: "truncate";
|
|
30
|
+
/**
|
|
31
|
+
* Whether to disable .gitignore files when listing files.
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
disableGitignore?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Glob pattern to filter entries by path.
|
|
37
|
+
* Examples: "*.ts", "**\/*.js", "src/**\/*.{ts,tsx}"
|
|
38
|
+
*/
|
|
39
|
+
pattern?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface AFSListResult {
|
|
42
|
+
data: AFSEntry[];
|
|
43
|
+
message?: string;
|
|
11
44
|
}
|
|
12
|
-
export interface AFSSearchOptions {
|
|
45
|
+
export interface AFSSearchOptions extends AFSOperationOptions {
|
|
13
46
|
limit?: number;
|
|
14
47
|
caseSensitive?: boolean;
|
|
15
48
|
}
|
|
16
|
-
export interface
|
|
49
|
+
export interface AFSSearchResult {
|
|
50
|
+
data: AFSEntry[];
|
|
51
|
+
message?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface AFSReadOptions extends AFSOperationOptions {
|
|
54
|
+
filter?: AFSListOptions["filter"];
|
|
55
|
+
}
|
|
56
|
+
export interface AFSReadResult {
|
|
57
|
+
data?: AFSEntry;
|
|
58
|
+
message?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface AFSDeleteOptions extends AFSOperationOptions {
|
|
17
61
|
recursive?: boolean;
|
|
18
62
|
}
|
|
19
|
-
export interface
|
|
63
|
+
export interface AFSDeleteResult {
|
|
64
|
+
message?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface AFSRenameOptions extends AFSOperationOptions {
|
|
20
67
|
overwrite?: boolean;
|
|
21
68
|
}
|
|
22
|
-
export interface
|
|
69
|
+
export interface AFSRenameResult {
|
|
70
|
+
message?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface AFSWriteOptions extends AFSOperationOptions {
|
|
23
73
|
append?: boolean;
|
|
24
74
|
}
|
|
75
|
+
export interface AFSWriteResult {
|
|
76
|
+
data: AFSEntry;
|
|
77
|
+
message?: string;
|
|
78
|
+
context?: any;
|
|
79
|
+
}
|
|
25
80
|
export interface AFSWriteEntryPayload extends Omit<AFSEntry, "id" | "path"> {
|
|
26
81
|
}
|
|
82
|
+
export interface AFSExecOptions extends AFSOperationOptions {
|
|
83
|
+
}
|
|
84
|
+
export interface AFSExecResult {
|
|
85
|
+
data: Record<string, any>;
|
|
86
|
+
}
|
|
27
87
|
export interface AFSModule {
|
|
28
88
|
readonly name: string;
|
|
29
89
|
readonly description?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Access mode for this module.
|
|
92
|
+
* - "readonly": Only read operations are allowed
|
|
93
|
+
* - "readwrite": All operations are allowed
|
|
94
|
+
* Default behavior is implementation-specific.
|
|
95
|
+
*/
|
|
96
|
+
readonly accessMode?: AFSAccessMode;
|
|
97
|
+
/**
|
|
98
|
+
* Enable automatic agent skill scanning for this module.
|
|
99
|
+
* When set to true, the system will scan this module for agent skills.
|
|
100
|
+
* @default false
|
|
101
|
+
*/
|
|
102
|
+
readonly agentSkills?: boolean;
|
|
30
103
|
onMount?(root: AFSRoot): void;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
104
|
+
symlinkToPhysical?(path: string): Promise<void>;
|
|
105
|
+
list?(path: string, options?: AFSListOptions): Promise<AFSListResult>;
|
|
106
|
+
read?(path: string, options?: AFSReadOptions): Promise<AFSReadResult>;
|
|
107
|
+
write?(path: string, content: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<AFSWriteResult>;
|
|
108
|
+
delete?(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
|
|
109
|
+
rename?(oldPath: string, newPath: string, options?: AFSRenameOptions): Promise<AFSRenameResult>;
|
|
110
|
+
search?(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;
|
|
111
|
+
exec?(path: string, args: Record<string, any>, options: AFSExecOptions): Promise<AFSExecResult>;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Parameters for loading a module from configuration.
|
|
115
|
+
*/
|
|
116
|
+
export interface AFSModuleLoadParams {
|
|
117
|
+
/** Path to the configuration file */
|
|
118
|
+
filepath: string;
|
|
119
|
+
/** Parsed configuration object */
|
|
120
|
+
parsed?: object;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Interface for module classes that support schema validation and loading from configuration.
|
|
124
|
+
* This describes the static part of a module class.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* class MyModule implements AFSModule {
|
|
129
|
+
* static schema() { return mySchema; }
|
|
130
|
+
* static async load(params: AFSModuleLoadParams) { ... }
|
|
131
|
+
* // ...
|
|
132
|
+
* }
|
|
133
|
+
*
|
|
134
|
+
* // Type check
|
|
135
|
+
* const _check: AFSModuleClass<MyModule, MyModuleOptions> = MyModule;
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export interface AFSModuleClass<T extends AFSModule = AFSModule, O extends object = object> {
|
|
139
|
+
/** Returns the Zod schema for validating module configuration */
|
|
140
|
+
schema(): ZodType<O>;
|
|
141
|
+
/** Loads a module instance from configuration file path and parsed config */
|
|
142
|
+
load(params: AFSModuleLoadParams): Promise<T>;
|
|
143
|
+
/** Constructor */
|
|
144
|
+
new (options: O): T;
|
|
58
145
|
}
|
|
59
146
|
export type AFSRootEvents = {
|
|
60
|
-
agentSucceed: [
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
147
|
+
agentSucceed: [
|
|
148
|
+
{
|
|
149
|
+
agentId?: string;
|
|
150
|
+
userId?: string;
|
|
151
|
+
sessionId?: string;
|
|
152
|
+
input: object;
|
|
153
|
+
output: object;
|
|
154
|
+
messages?: object[];
|
|
155
|
+
}
|
|
156
|
+
];
|
|
64
157
|
historyCreated: [{
|
|
65
158
|
entry: AFSEntry;
|
|
66
|
-
}];
|
|
159
|
+
}, options: AFSOperationOptions];
|
|
67
160
|
};
|
|
161
|
+
export interface AFSRootListOptions extends AFSListOptions, AFSContextPreset {
|
|
162
|
+
preset?: string;
|
|
163
|
+
}
|
|
164
|
+
export interface AFSRootListResult extends Omit<AFSListResult, "data"> {
|
|
165
|
+
data: any;
|
|
166
|
+
}
|
|
167
|
+
export interface AFSRootSearchOptions extends AFSSearchOptions, AFSContextPreset {
|
|
168
|
+
preset?: string;
|
|
169
|
+
}
|
|
170
|
+
export interface AFSRootSearchResult extends Omit<AFSSearchResult, "data"> {
|
|
171
|
+
data: any;
|
|
172
|
+
}
|
|
68
173
|
export interface AFSRoot extends Emitter<AFSRootEvents>, AFSModule {
|
|
174
|
+
list(path: string, options?: AFSRootListOptions): Promise<AFSRootListResult>;
|
|
175
|
+
search(path: string, query: string, options: AFSRootSearchOptions): Promise<AFSRootSearchResult>;
|
|
176
|
+
initializePhysicalPath(): Promise<string>;
|
|
177
|
+
cleanupPhysicalPath(): Promise<void>;
|
|
69
178
|
}
|
|
70
179
|
export interface AFSEntryMetadata extends Record<string, any> {
|
|
71
180
|
execute?: {
|
|
@@ -75,12 +184,15 @@ export interface AFSEntryMetadata extends Record<string, any> {
|
|
|
75
184
|
outputSchema?: Record<string, any>;
|
|
76
185
|
};
|
|
77
186
|
childrenCount?: number;
|
|
187
|
+
childrenTruncated?: boolean;
|
|
188
|
+
gitignored?: boolean;
|
|
78
189
|
}
|
|
79
190
|
export interface AFSEntry<T = any> {
|
|
80
191
|
id: string;
|
|
81
192
|
createdAt?: Date;
|
|
82
193
|
updatedAt?: Date;
|
|
83
194
|
path: string;
|
|
195
|
+
agentId?: string | null;
|
|
84
196
|
userId?: string | null;
|
|
85
197
|
sessionId?: string | null;
|
|
86
198
|
summary?: string | null;
|
|
@@ -89,3 +201,42 @@ export interface AFSEntry<T = any> {
|
|
|
89
201
|
linkTo?: string | null;
|
|
90
202
|
content?: T;
|
|
91
203
|
}
|
|
204
|
+
export declare const afsEntrySchema: ZodType<AFSEntry>;
|
|
205
|
+
export interface AFSContextPreset {
|
|
206
|
+
/**
|
|
207
|
+
* The view template for presenting the search results.
|
|
208
|
+
*/
|
|
209
|
+
view?: string;
|
|
210
|
+
select?: AFSContextPresetOptionAgent<{
|
|
211
|
+
path: string;
|
|
212
|
+
query?: string;
|
|
213
|
+
}, {
|
|
214
|
+
data: string[];
|
|
215
|
+
}>;
|
|
216
|
+
per?: AFSContextPresetOptionAgent<{
|
|
217
|
+
data: AFSEntry;
|
|
218
|
+
}, {
|
|
219
|
+
data: unknown;
|
|
220
|
+
}>;
|
|
221
|
+
dedupe?: AFSContextPresetOptionAgent<{
|
|
222
|
+
data: unknown[];
|
|
223
|
+
}, {
|
|
224
|
+
data: unknown;
|
|
225
|
+
}>;
|
|
226
|
+
format?: "default" | "simple-list" | "tree" | AFSContextPresetOptionAgent<{
|
|
227
|
+
data: unknown;
|
|
228
|
+
}, {
|
|
229
|
+
data: unknown;
|
|
230
|
+
}>;
|
|
231
|
+
}
|
|
232
|
+
export interface AFSContextPresetOptionAgent<I = any, O = any> {
|
|
233
|
+
invoke(input: I, options?: any): Promise<O>;
|
|
234
|
+
}
|
|
235
|
+
export interface AFSContext {
|
|
236
|
+
search?: {
|
|
237
|
+
presets?: Record<string, AFSContextPreset>;
|
|
238
|
+
};
|
|
239
|
+
list?: {
|
|
240
|
+
presets?: Record<string, AFSContextPreset>;
|
|
241
|
+
};
|
|
242
|
+
}
|
package/lib/esm/type.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema for access mode validation.
|
|
4
|
+
* Can be reused across modules that support access mode configuration.
|
|
5
|
+
*/
|
|
6
|
+
export const accessModeSchema = z
|
|
7
|
+
.enum(["readonly", "readwrite"])
|
|
8
|
+
.describe("Access mode for this module")
|
|
9
|
+
.optional();
|
|
10
|
+
export const afsEntrySchema = z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
createdAt: z.date().optional(),
|
|
13
|
+
updatedAt: z.date().optional(),
|
|
14
|
+
path: z.string(),
|
|
15
|
+
userId: z.string().nullable().optional(),
|
|
16
|
+
sessionId: z.string().nullable().optional(),
|
|
17
|
+
summary: z.string().nullable().optional(),
|
|
18
|
+
description: z.string().nullable().optional(),
|
|
19
|
+
metadata: z.record(z.any()).nullable().optional(),
|
|
20
|
+
linkTo: z.string().nullable().optional(),
|
|
21
|
+
content: z.any().optional(),
|
|
22
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/afs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-beta.10",
|
|
4
4
|
"description": "Agentic File System (AFS) is a virtual file system that supports various storage backends and provides a unified API for file operations.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -47,8 +47,12 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
+
"@aigne/uuid": "^13.0.1",
|
|
50
51
|
"strict-event-emitter": "^0.5.1",
|
|
51
|
-
"ufo": "^1.6.1"
|
|
52
|
+
"ufo": "^1.6.1",
|
|
53
|
+
"yaml": "^2.8.1",
|
|
54
|
+
"zod": "^3.25.67",
|
|
55
|
+
"@aigne/platform-helpers": "^0.6.7-beta.2"
|
|
52
56
|
},
|
|
53
57
|
"devDependencies": {
|
|
54
58
|
"@types/bun": "^1.2.22",
|