@aigne/afs 1.4.0-beta.1 → 1.4.0-beta.11

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/lib/esm/type.d.ts CHANGED
@@ -1,9 +1,26 @@
1
1
  import type { Emitter } from "strict-event-emitter";
2
- import { type ZodType } from "zod";
3
- export interface AFSListOptions {
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 {
4
18
  filter?: {
19
+ agentId?: string;
5
20
  userId?: string;
6
21
  sessionId?: string;
22
+ before?: string;
23
+ after?: string;
7
24
  };
8
25
  maxDepth?: number;
9
26
  limit?: number;
@@ -15,46 +32,45 @@ export interface AFSListOptions {
15
32
  * @default false
16
33
  */
17
34
  disableGitignore?: boolean;
18
- context?: any;
35
+ /**
36
+ * Glob pattern to filter entries by path.
37
+ * Examples: "*.ts", "**\/*.js", "src/**\/*.{ts,tsx}"
38
+ */
39
+ pattern?: string;
19
40
  }
20
41
  export interface AFSListResult {
21
42
  data: AFSEntry[];
22
43
  message?: string;
23
- context?: any;
24
44
  }
25
- export interface AFSSearchOptions {
45
+ export interface AFSSearchOptions extends AFSOperationOptions {
26
46
  limit?: number;
27
47
  caseSensitive?: boolean;
28
- context?: any;
29
48
  }
30
49
  export interface AFSSearchResult {
31
50
  data: AFSEntry[];
32
51
  message?: string;
33
52
  }
34
- export interface AFSReadOptions {
35
- context?: any;
53
+ export interface AFSReadOptions extends AFSOperationOptions {
54
+ filter?: AFSListOptions["filter"];
36
55
  }
37
56
  export interface AFSReadResult {
38
57
  data?: AFSEntry;
39
58
  message?: string;
40
59
  }
41
- export interface AFSDeleteOptions {
60
+ export interface AFSDeleteOptions extends AFSOperationOptions {
42
61
  recursive?: boolean;
43
- context?: any;
44
62
  }
45
63
  export interface AFSDeleteResult {
46
64
  message?: string;
47
65
  }
48
- export interface AFSRenameOptions {
66
+ export interface AFSRenameOptions extends AFSOperationOptions {
49
67
  overwrite?: boolean;
50
- context?: any;
51
68
  }
52
69
  export interface AFSRenameResult {
53
70
  message?: string;
54
71
  }
55
- export interface AFSWriteOptions {
72
+ export interface AFSWriteOptions extends AFSOperationOptions {
56
73
  append?: boolean;
57
- context?: any;
58
74
  }
59
75
  export interface AFSWriteResult {
60
76
  data: AFSEntry;
@@ -63,8 +79,7 @@ export interface AFSWriteResult {
63
79
  }
64
80
  export interface AFSWriteEntryPayload extends Omit<AFSEntry, "id" | "path"> {
65
81
  }
66
- export interface AFSExecOptions {
67
- context: any;
82
+ export interface AFSExecOptions extends AFSOperationOptions {
68
83
  }
69
84
  export interface AFSExecResult {
70
85
  data: Record<string, any>;
@@ -72,7 +87,21 @@ export interface AFSExecResult {
72
87
  export interface AFSModule {
73
88
  readonly name: string;
74
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;
75
103
  onMount?(root: AFSRoot): void;
104
+ symlinkToPhysical?(path: string): Promise<void>;
76
105
  list?(path: string, options?: AFSListOptions): Promise<AFSListResult>;
77
106
  read?(path: string, options?: AFSReadOptions): Promise<AFSReadResult>;
78
107
  write?(path: string, content: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<AFSWriteResult>;
@@ -81,14 +110,53 @@ export interface AFSModule {
81
110
  search?(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;
82
111
  exec?(path: string, args: Record<string, any>, options: AFSExecOptions): Promise<AFSExecResult>;
83
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;
145
+ }
84
146
  export type AFSRootEvents = {
85
- agentSucceed: [{
86
- input: object;
87
- output: object;
88
- }];
147
+ agentSucceed: [
148
+ {
149
+ agentId?: string;
150
+ userId?: string;
151
+ sessionId?: string;
152
+ input: object;
153
+ output: object;
154
+ messages?: object[];
155
+ }
156
+ ];
89
157
  historyCreated: [{
90
158
  entry: AFSEntry;
91
- }];
159
+ }, options: AFSOperationOptions];
92
160
  };
93
161
  export interface AFSRootListOptions extends AFSListOptions, AFSContextPreset {
94
162
  preset?: string;
@@ -105,6 +173,8 @@ export interface AFSRootSearchResult extends Omit<AFSSearchResult, "data"> {
105
173
  export interface AFSRoot extends Emitter<AFSRootEvents>, AFSModule {
106
174
  list(path: string, options?: AFSRootListOptions): Promise<AFSRootListResult>;
107
175
  search(path: string, query: string, options: AFSRootSearchOptions): Promise<AFSRootSearchResult>;
176
+ initializePhysicalPath(): Promise<string>;
177
+ cleanupPhysicalPath(): Promise<void>;
108
178
  }
109
179
  export interface AFSEntryMetadata extends Record<string, any> {
110
180
  execute?: {
@@ -115,12 +185,14 @@ export interface AFSEntryMetadata extends Record<string, any> {
115
185
  };
116
186
  childrenCount?: number;
117
187
  childrenTruncated?: boolean;
188
+ gitignored?: boolean;
118
189
  }
119
190
  export interface AFSEntry<T = any> {
120
191
  id: string;
121
192
  createdAt?: Date;
122
193
  updatedAt?: Date;
123
194
  path: string;
195
+ agentId?: string | null;
124
196
  userId?: string | null;
125
197
  sessionId?: string | null;
126
198
  summary?: string | null;
@@ -151,7 +223,7 @@ export interface AFSContextPreset {
151
223
  }, {
152
224
  data: unknown;
153
225
  }>;
154
- format?: "default" | "tree" | AFSContextPresetOptionAgent<{
226
+ format?: "default" | "simple-list" | "tree" | AFSContextPresetOptionAgent<{
155
227
  data: unknown;
156
228
  }, {
157
229
  data: unknown;
package/lib/esm/type.js CHANGED
@@ -1,4 +1,12 @@
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();
2
10
  export const afsEntrySchema = z.object({
3
11
  id: z.string(),
4
12
  createdAt: z.date().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/afs",
3
- "version": "1.4.0-beta.1",
3
+ "version": "1.4.0-beta.11",
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,9 +47,12 @@
47
47
  }
48
48
  },
49
49
  "dependencies": {
50
+ "@aigne/uuid": "^13.0.1",
50
51
  "strict-event-emitter": "^0.5.1",
51
52
  "ufo": "^1.6.1",
52
- "zod": "^3.25.67"
53
+ "yaml": "^2.8.1",
54
+ "zod": "^3.25.67",
55
+ "@aigne/platform-helpers": "^0.6.7-beta.2"
53
56
  },
54
57
  "devDependencies": {
55
58
  "@types/bun": "^1.2.22",