@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/lib/cjs/type.d.ts CHANGED
@@ -1,71 +1,180 @@
1
1
  import type { Emitter } from "strict-event-emitter";
2
- 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 {
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 AFSDeleteOptions {
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 AFSRenameOptions {
63
+ export interface AFSDeleteResult {
64
+ message?: string;
65
+ }
66
+ export interface AFSRenameOptions extends AFSOperationOptions {
20
67
  overwrite?: boolean;
21
68
  }
22
- export interface AFSWriteOptions {
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
- list?(path: string, options?: AFSListOptions): Promise<{
32
- list: AFSEntry[];
33
- message?: string;
34
- }>;
35
- read?(path: string): Promise<{
36
- result?: AFSEntry;
37
- message?: string;
38
- }>;
39
- write?(path: string, content: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<{
40
- result: AFSEntry;
41
- message?: string;
42
- }>;
43
- delete?(path: string, options?: AFSDeleteOptions): Promise<{
44
- message?: string;
45
- }>;
46
- rename?(oldPath: string, newPath: string, options?: AFSRenameOptions): Promise<{
47
- message?: string;
48
- }>;
49
- search?(path: string, query: string, options?: AFSSearchOptions): Promise<{
50
- list: AFSEntry[];
51
- message?: string;
52
- }>;
53
- exec?(path: string, args: Record<string, any>, options: {
54
- context: any;
55
- }): Promise<{
56
- result: Record<string, any>;
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
- input: object;
62
- output: object;
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/cjs/type.js CHANGED
@@ -1,2 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.afsEntrySchema = exports.accessModeSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Zod schema for access mode validation.
7
+ * Can be reused across modules that support access mode configuration.
8
+ */
9
+ exports.accessModeSchema = zod_1.z
10
+ .enum(["readonly", "readwrite"])
11
+ .describe("Access mode for this module")
12
+ .optional();
13
+ exports.afsEntrySchema = zod_1.z.object({
14
+ id: zod_1.z.string(),
15
+ createdAt: zod_1.z.date().optional(),
16
+ updatedAt: zod_1.z.date().optional(),
17
+ path: zod_1.z.string(),
18
+ userId: zod_1.z.string().nullable().optional(),
19
+ sessionId: zod_1.z.string().nullable().optional(),
20
+ summary: zod_1.z.string().nullable().optional(),
21
+ description: zod_1.z.string().nullable().optional(),
22
+ metadata: zod_1.z.record(zod_1.z.any()).nullable().optional(),
23
+ linkTo: zod_1.z.string().nullable().optional(),
24
+ content: zod_1.z.any().optional(),
25
+ });
package/lib/dts/afs.d.ts CHANGED
@@ -1,12 +1,19 @@
1
1
  import { Emitter } from "strict-event-emitter";
2
- import type { AFSDeleteOptions, AFSEntry, AFSListOptions, AFSModule, AFSRenameOptions, AFSRoot, AFSRootEvents, AFSSearchOptions, AFSWriteEntryPayload, AFSWriteOptions } from "./type.js";
2
+ import { type AFSContext, type AFSDeleteOptions, type AFSDeleteResult, type AFSExecOptions, type AFSExecResult, type AFSModule, type AFSReadOptions, type AFSReadResult, type AFSRenameOptions, type AFSRenameResult, type AFSRoot, type AFSRootEvents, type AFSRootListOptions, type AFSRootListResult, type AFSRootSearchOptions, type AFSRootSearchResult, type AFSWriteEntryPayload, type AFSWriteOptions, type AFSWriteResult } from "./type.js";
3
3
  export interface AFSOptions {
4
4
  modules?: AFSModule[];
5
+ context?: AFSContext;
5
6
  }
6
7
  export declare class AFS extends Emitter<AFSRootEvents> implements AFSRoot {
8
+ options: AFSOptions;
7
9
  name: string;
8
10
  constructor(options?: AFSOptions);
9
11
  private modules;
12
+ /**
13
+ * Check if write operations are allowed for the given module.
14
+ * Throws AFSReadonlyError if not allowed.
15
+ */
16
+ private checkWritePermission;
10
17
  mount(module: AFSModule): this;
11
18
  listModules(): Promise<{
12
19
  name: string;
@@ -14,32 +21,22 @@ export declare class AFS extends Emitter<AFSRootEvents> implements AFSRoot {
14
21
  description?: string;
15
22
  module: AFSModule;
16
23
  }[]>;
17
- list(path: string, options?: AFSListOptions): Promise<{
18
- list: AFSEntry[];
19
- message?: string;
20
- }>;
21
- read(path: string): Promise<{
22
- result?: AFSEntry;
23
- message?: string;
24
- }>;
25
- write(path: string, content: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<{
26
- result: AFSEntry;
27
- message?: string;
28
- }>;
29
- delete(path: string, options?: AFSDeleteOptions): Promise<{
30
- message?: string;
31
- }>;
32
- rename(oldPath: string, newPath: string, options?: AFSRenameOptions): Promise<{
33
- message?: string;
34
- }>;
35
- search(path: string, query: string, options?: AFSSearchOptions): Promise<{
36
- list: AFSEntry[];
37
- message?: string;
38
- }>;
24
+ list(path: string, options?: AFSRootListOptions): Promise<AFSRootListResult>;
25
+ private _list;
26
+ read(path: string, _options?: AFSReadOptions): Promise<AFSReadResult>;
27
+ write(path: string, content: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<AFSWriteResult>;
28
+ delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
29
+ rename(oldPath: string, newPath: string, options?: AFSRenameOptions): Promise<AFSRenameResult>;
30
+ search(path: string, query: string, options?: AFSRootSearchOptions): Promise<AFSRootSearchResult>;
31
+ private processWithPreset;
32
+ private _select;
33
+ private _search;
39
34
  private findModules;
40
- exec(path: string, args: Record<string, any>, options: {
41
- context: any;
42
- }): Promise<{
43
- result: Record<string, any>;
44
- }>;
35
+ exec(path: string, args: Record<string, any>, options: AFSExecOptions): Promise<AFSExecResult>;
36
+ private buildSimpleListView;
37
+ private buildTreeView;
38
+ private buildMetadataSuffix;
39
+ private physicalPath?;
40
+ initializePhysicalPath(): Promise<string>;
41
+ cleanupPhysicalPath(): Promise<void>;
45
42
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Base error class for all AFS errors.
3
+ */
4
+ export declare class AFSError extends Error {
5
+ readonly code: string;
6
+ constructor(message: string, code: string);
7
+ }
8
+ /**
9
+ * Error thrown when attempting write operations on a readonly AFS or module.
10
+ */
11
+ export declare class AFSReadonlyError extends AFSError {
12
+ constructor(message: string);
13
+ }
@@ -1,2 +1,3 @@
1
1
  export * from "./afs.js";
2
+ export * from "./error.js";
2
3
  export * from "./type.js";
package/lib/dts/type.d.ts CHANGED
@@ -1,71 +1,180 @@
1
1
  import type { Emitter } from "strict-event-emitter";
2
- 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 {
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 AFSDeleteOptions {
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 AFSRenameOptions {
63
+ export interface AFSDeleteResult {
64
+ message?: string;
65
+ }
66
+ export interface AFSRenameOptions extends AFSOperationOptions {
20
67
  overwrite?: boolean;
21
68
  }
22
- export interface AFSWriteOptions {
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
- list?(path: string, options?: AFSListOptions): Promise<{
32
- list: AFSEntry[];
33
- message?: string;
34
- }>;
35
- read?(path: string): Promise<{
36
- result?: AFSEntry;
37
- message?: string;
38
- }>;
39
- write?(path: string, content: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<{
40
- result: AFSEntry;
41
- message?: string;
42
- }>;
43
- delete?(path: string, options?: AFSDeleteOptions): Promise<{
44
- message?: string;
45
- }>;
46
- rename?(oldPath: string, newPath: string, options?: AFSRenameOptions): Promise<{
47
- message?: string;
48
- }>;
49
- search?(path: string, query: string, options?: AFSSearchOptions): Promise<{
50
- list: AFSEntry[];
51
- message?: string;
52
- }>;
53
- exec?(path: string, args: Record<string, any>, options: {
54
- context: any;
55
- }): Promise<{
56
- result: Record<string, any>;
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
- input: object;
62
- output: object;
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
+ }