@aigne/afs 1.11.0-beta → 1.11.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.
Files changed (164) hide show
  1. package/LICENSE.md +17 -84
  2. package/README.md +4 -13
  3. package/dist/_virtual/rolldown_runtime.mjs +7 -0
  4. package/dist/afs.cjs +1330 -0
  5. package/dist/afs.d.cts +275 -0
  6. package/dist/afs.d.cts.map +1 -0
  7. package/dist/afs.d.mts +275 -0
  8. package/dist/afs.d.mts.map +1 -0
  9. package/dist/afs.mjs +1331 -0
  10. package/dist/afs.mjs.map +1 -0
  11. package/dist/capabilities/index.d.mts +2 -0
  12. package/dist/capabilities/types.d.cts +100 -0
  13. package/dist/capabilities/types.d.cts.map +1 -0
  14. package/dist/capabilities/types.d.mts +100 -0
  15. package/dist/capabilities/types.d.mts.map +1 -0
  16. package/dist/capabilities/world-mapping.cjs +20 -0
  17. package/dist/capabilities/world-mapping.d.cts +139 -0
  18. package/dist/capabilities/world-mapping.d.cts.map +1 -0
  19. package/dist/capabilities/world-mapping.d.mts +139 -0
  20. package/dist/capabilities/world-mapping.d.mts.map +1 -0
  21. package/dist/capabilities/world-mapping.mjs +20 -0
  22. package/dist/capabilities/world-mapping.mjs.map +1 -0
  23. package/dist/error.cjs +63 -0
  24. package/dist/error.d.cts +39 -0
  25. package/dist/error.d.cts.map +1 -0
  26. package/dist/error.d.mts +39 -0
  27. package/dist/error.d.mts.map +1 -0
  28. package/dist/error.mjs +59 -0
  29. package/dist/error.mjs.map +1 -0
  30. package/dist/index.cjs +72 -345
  31. package/dist/index.d.cts +18 -300
  32. package/dist/index.d.mts +20 -300
  33. package/dist/index.mjs +16 -342
  34. package/dist/loader/index.cjs +110 -0
  35. package/dist/loader/index.d.cts +48 -0
  36. package/dist/loader/index.d.cts.map +1 -0
  37. package/dist/loader/index.d.mts +48 -0
  38. package/dist/loader/index.d.mts.map +1 -0
  39. package/dist/loader/index.mjs +110 -0
  40. package/dist/loader/index.mjs.map +1 -0
  41. package/dist/meta/index.cjs +4 -0
  42. package/dist/meta/index.mjs +6 -0
  43. package/dist/meta/kind.cjs +161 -0
  44. package/dist/meta/kind.d.cts +134 -0
  45. package/dist/meta/kind.d.cts.map +1 -0
  46. package/dist/meta/kind.d.mts +134 -0
  47. package/dist/meta/kind.d.mts.map +1 -0
  48. package/dist/meta/kind.mjs +157 -0
  49. package/dist/meta/kind.mjs.map +1 -0
  50. package/dist/meta/path.cjs +116 -0
  51. package/dist/meta/path.d.cts +43 -0
  52. package/dist/meta/path.d.cts.map +1 -0
  53. package/dist/meta/path.d.mts +43 -0
  54. package/dist/meta/path.d.mts.map +1 -0
  55. package/dist/meta/path.mjs +112 -0
  56. package/dist/meta/path.mjs.map +1 -0
  57. package/dist/meta/type.d.cts +96 -0
  58. package/dist/meta/type.d.cts.map +1 -0
  59. package/dist/meta/type.d.mts +96 -0
  60. package/dist/meta/type.d.mts.map +1 -0
  61. package/dist/meta/validation.cjs +77 -0
  62. package/dist/meta/validation.d.cts +19 -0
  63. package/dist/meta/validation.d.cts.map +1 -0
  64. package/dist/meta/validation.d.mts +19 -0
  65. package/dist/meta/validation.d.mts.map +1 -0
  66. package/dist/meta/validation.mjs +77 -0
  67. package/dist/meta/validation.mjs.map +1 -0
  68. package/dist/meta/well-known-kinds.cjs +228 -0
  69. package/dist/meta/well-known-kinds.d.cts +52 -0
  70. package/dist/meta/well-known-kinds.d.cts.map +1 -0
  71. package/dist/meta/well-known-kinds.d.mts +52 -0
  72. package/dist/meta/well-known-kinds.d.mts.map +1 -0
  73. package/dist/meta/well-known-kinds.mjs +219 -0
  74. package/dist/meta/well-known-kinds.mjs.map +1 -0
  75. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.cts +141 -0
  76. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.cts.map +1 -0
  77. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.mts +141 -0
  78. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.mts.map +1 -0
  79. package/dist/path.cjs +255 -0
  80. package/dist/path.d.cts +93 -0
  81. package/dist/path.d.cts.map +1 -0
  82. package/dist/path.d.mts +93 -0
  83. package/dist/path.d.mts.map +1 -0
  84. package/dist/path.mjs +249 -0
  85. package/dist/path.mjs.map +1 -0
  86. package/dist/provider/base.cjs +425 -0
  87. package/dist/provider/base.d.cts +175 -0
  88. package/dist/provider/base.d.cts.map +1 -0
  89. package/dist/provider/base.d.mts +175 -0
  90. package/dist/provider/base.d.mts.map +1 -0
  91. package/dist/provider/base.mjs +426 -0
  92. package/dist/provider/base.mjs.map +1 -0
  93. package/dist/provider/decorators.cjs +268 -0
  94. package/dist/provider/decorators.d.cts +244 -0
  95. package/dist/provider/decorators.d.cts.map +1 -0
  96. package/dist/provider/decorators.d.mts +244 -0
  97. package/dist/provider/decorators.d.mts.map +1 -0
  98. package/dist/provider/decorators.mjs +256 -0
  99. package/dist/provider/decorators.mjs.map +1 -0
  100. package/dist/provider/index.cjs +19 -0
  101. package/dist/provider/index.d.cts +5 -0
  102. package/dist/provider/index.d.mts +5 -0
  103. package/dist/provider/index.mjs +5 -0
  104. package/dist/provider/router.cjs +185 -0
  105. package/dist/provider/router.d.cts +50 -0
  106. package/dist/provider/router.d.cts.map +1 -0
  107. package/dist/provider/router.d.mts +50 -0
  108. package/dist/provider/router.d.mts.map +1 -0
  109. package/dist/provider/router.mjs +185 -0
  110. package/dist/provider/router.mjs.map +1 -0
  111. package/dist/provider/types.d.cts +113 -0
  112. package/dist/provider/types.d.cts.map +1 -0
  113. package/dist/provider/types.d.mts +113 -0
  114. package/dist/provider/types.d.mts.map +1 -0
  115. package/dist/registry.cjs +358 -0
  116. package/dist/registry.d.cts +96 -0
  117. package/dist/registry.d.cts.map +1 -0
  118. package/dist/registry.d.mts +96 -0
  119. package/dist/registry.d.mts.map +1 -0
  120. package/dist/registry.mjs +360 -0
  121. package/dist/registry.mjs.map +1 -0
  122. package/dist/type.cjs +34 -0
  123. package/dist/type.d.cts +420 -0
  124. package/dist/type.d.cts.map +1 -0
  125. package/dist/type.d.mts +420 -0
  126. package/dist/type.d.mts.map +1 -0
  127. package/dist/type.mjs +33 -0
  128. package/dist/type.mjs.map +1 -0
  129. package/dist/utils/camelize.d.cts.map +1 -1
  130. package/dist/utils/camelize.d.mts.map +1 -1
  131. package/dist/utils/schema.cjs +129 -0
  132. package/dist/utils/schema.d.cts +65 -0
  133. package/dist/utils/schema.d.cts.map +1 -0
  134. package/dist/utils/schema.d.mts +65 -0
  135. package/dist/utils/schema.d.mts.map +1 -0
  136. package/dist/utils/schema.mjs +124 -0
  137. package/dist/utils/schema.mjs.map +1 -0
  138. package/dist/utils/type-utils.d.cts.map +1 -1
  139. package/dist/utils/type-utils.d.mts.map +1 -1
  140. package/dist/utils/uri-template.cjs +123 -0
  141. package/dist/utils/uri-template.d.cts +48 -0
  142. package/dist/utils/uri-template.d.cts.map +1 -0
  143. package/dist/utils/uri-template.d.mts +48 -0
  144. package/dist/utils/uri-template.d.mts.map +1 -0
  145. package/dist/utils/uri-template.mjs +120 -0
  146. package/dist/utils/uri-template.mjs.map +1 -0
  147. package/dist/utils/uri.cjs +49 -0
  148. package/dist/utils/uri.d.cts +34 -0
  149. package/dist/utils/uri.d.cts.map +1 -0
  150. package/dist/utils/uri.d.mts +34 -0
  151. package/dist/utils/uri.d.mts.map +1 -0
  152. package/dist/utils/uri.mjs +49 -0
  153. package/dist/utils/uri.mjs.map +1 -0
  154. package/dist/utils/zod.cjs +6 -8
  155. package/dist/utils/zod.d.cts +2 -2
  156. package/dist/utils/zod.d.cts.map +1 -1
  157. package/dist/utils/zod.d.mts +2 -2
  158. package/dist/utils/zod.d.mts.map +1 -1
  159. package/dist/utils/zod.mjs +6 -8
  160. package/dist/utils/zod.mjs.map +1 -1
  161. package/package.json +27 -4
  162. package/dist/index.d.cts.map +0 -1
  163. package/dist/index.d.mts.map +0 -1
  164. package/dist/index.mjs.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,300 +1,18 @@
1
- import { Emitter } from "strict-event-emitter";
2
- import { ZodType, z } from "zod";
3
-
4
- //#region src/type.d.ts
5
- /**
6
- * Access mode for AFS modules and root.
7
- * - "readonly": Only read operations are allowed (list, read, search)
8
- * - "readwrite": All operations are allowed
9
- */
10
- type AFSAccessMode = "readonly" | "readwrite";
11
- /**
12
- * Zod schema for access mode validation.
13
- * Can be reused across modules that support access mode configuration.
14
- */
15
- declare const accessModeSchema: z.ZodOptional<z.ZodEnum<["readonly", "readwrite"]>>;
16
- interface AFSOperationOptions {
17
- context?: any;
18
- }
19
- interface AFSListOptions extends AFSOperationOptions {
20
- filter?: {
21
- agentId?: string;
22
- userId?: string;
23
- sessionId?: string;
24
- before?: string;
25
- after?: string;
26
- };
27
- maxDepth?: number;
28
- limit?: number;
29
- orderBy?: [string, "asc" | "desc"][];
30
- maxChildren?: number;
31
- onOverflow?: "truncate";
32
- /**
33
- * Whether to disable .gitignore files when listing files.
34
- * @default false
35
- */
36
- disableGitignore?: boolean;
37
- /**
38
- * Glob pattern to filter entries by path.
39
- * Examples: "*.ts", "**\/*.js", "src/**\/*.{ts,tsx}"
40
- */
41
- pattern?: string;
42
- }
43
- interface AFSListResult {
44
- data: AFSEntry[];
45
- message?: string;
46
- }
47
- interface AFSSearchOptions extends AFSOperationOptions {
48
- limit?: number;
49
- caseSensitive?: boolean;
50
- }
51
- interface AFSSearchResult {
52
- data: AFSEntry[];
53
- message?: string;
54
- }
55
- interface AFSReadOptions extends AFSOperationOptions {
56
- filter?: AFSListOptions["filter"];
57
- }
58
- interface AFSReadResult {
59
- data?: AFSEntry;
60
- message?: string;
61
- }
62
- interface AFSDeleteOptions extends AFSOperationOptions {
63
- recursive?: boolean;
64
- }
65
- interface AFSDeleteResult {
66
- message?: string;
67
- }
68
- interface AFSRenameOptions extends AFSOperationOptions {
69
- overwrite?: boolean;
70
- }
71
- interface AFSRenameResult {
72
- message?: string;
73
- }
74
- interface AFSWriteOptions extends AFSOperationOptions {
75
- append?: boolean;
76
- }
77
- interface AFSWriteResult {
78
- data: AFSEntry;
79
- message?: string;
80
- context?: any;
81
- }
82
- interface AFSWriteEntryPayload extends Omit<AFSEntry, "id" | "path"> {}
83
- interface AFSExecOptions extends AFSOperationOptions {}
84
- interface AFSExecResult {
85
- data: Record<string, any>;
86
- }
87
- interface AFSModule {
88
- readonly name: string;
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;
103
- onMount?(root: AFSRoot): void;
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
- 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
- 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
- }
146
- type AFSRootEvents = {
147
- agentSucceed: [{
148
- agentId?: string;
149
- userId?: string;
150
- sessionId?: string;
151
- input: object;
152
- output: object;
153
- messages?: object[];
154
- }];
155
- historyCreated: [{
156
- entry: AFSEntry;
157
- }, options: AFSOperationOptions];
158
- };
159
- interface AFSRootListOptions extends AFSListOptions, AFSContextPreset {
160
- preset?: string;
161
- }
162
- interface AFSRootListResult extends Omit<AFSListResult, "data"> {
163
- data: any;
164
- }
165
- interface AFSRootSearchOptions extends AFSSearchOptions, AFSContextPreset {
166
- preset?: string;
167
- }
168
- interface AFSRootSearchResult extends Omit<AFSSearchResult, "data"> {
169
- data: any;
170
- }
171
- interface AFSRoot extends Emitter<AFSRootEvents>, AFSModule {
172
- list(path: string, options?: AFSRootListOptions): Promise<AFSRootListResult>;
173
- search(path: string, query: string, options: AFSRootSearchOptions): Promise<AFSRootSearchResult>;
174
- initializePhysicalPath(): Promise<string>;
175
- cleanupPhysicalPath(): Promise<void>;
176
- }
177
- interface AFSEntryMetadata extends Record<string, any> {
178
- execute?: {
179
- name: string;
180
- description?: string;
181
- inputSchema?: Record<string, any>;
182
- outputSchema?: Record<string, any>;
183
- };
184
- childrenCount?: number;
185
- childrenTruncated?: boolean;
186
- gitignored?: boolean;
187
- }
188
- interface AFSEntry<T = any> {
189
- id: string;
190
- createdAt?: Date;
191
- updatedAt?: Date;
192
- path: string;
193
- agentId?: string | null;
194
- userId?: string | null;
195
- sessionId?: string | null;
196
- summary?: string | null;
197
- description?: string | null;
198
- metadata?: AFSEntryMetadata | null;
199
- linkTo?: string | null;
200
- content?: T;
201
- }
202
- declare const afsEntrySchema: ZodType<AFSEntry>;
203
- interface AFSContextPreset {
204
- /**
205
- * The view template for presenting the search results.
206
- */
207
- view?: string;
208
- select?: AFSContextPresetOptionAgent<{
209
- path: string;
210
- query?: string;
211
- }, {
212
- data: string[];
213
- }>;
214
- per?: AFSContextPresetOptionAgent<{
215
- data: AFSEntry;
216
- }, {
217
- data: unknown;
218
- }>;
219
- dedupe?: AFSContextPresetOptionAgent<{
220
- data: unknown[];
221
- }, {
222
- data: unknown;
223
- }>;
224
- format?: "default" | "simple-list" | "tree" | AFSContextPresetOptionAgent<{
225
- data: unknown;
226
- }, {
227
- data: unknown;
228
- }>;
229
- }
230
- interface AFSContextPresetOptionAgent<I = any, O = any> {
231
- invoke(input: I, options?: any): Promise<O>;
232
- }
233
- interface AFSContext {
234
- search?: {
235
- presets?: Record<string, AFSContextPreset>;
236
- };
237
- list?: {
238
- presets?: Record<string, AFSContextPreset>;
239
- };
240
- }
241
- //#endregion
242
- //#region src/afs.d.ts
243
- interface AFSOptions {
244
- modules?: AFSModule[];
245
- context?: AFSContext;
246
- }
247
- declare class AFS extends Emitter<AFSRootEvents> implements AFSRoot {
248
- options: AFSOptions;
249
- name: string;
250
- constructor(options?: AFSOptions);
251
- private modules;
252
- /**
253
- * Check if write operations are allowed for the given module.
254
- * Throws AFSReadonlyError if not allowed.
255
- */
256
- private checkWritePermission;
257
- mount(module: AFSModule): this;
258
- listModules(): Promise<{
259
- name: string;
260
- path: string;
261
- description?: string;
262
- module: AFSModule;
263
- }[]>;
264
- list(path: string, options?: AFSRootListOptions): Promise<AFSRootListResult>;
265
- private _list;
266
- read(path: string, _options?: AFSReadOptions): Promise<AFSReadResult>;
267
- write(path: string, content: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<AFSWriteResult>;
268
- delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
269
- rename(oldPath: string, newPath: string, options?: AFSRenameOptions): Promise<AFSRenameResult>;
270
- search(path: string, query: string, options?: AFSRootSearchOptions): Promise<AFSRootSearchResult>;
271
- private processWithPreset;
272
- private _select;
273
- private _search;
274
- private findModules;
275
- exec(path: string, args: Record<string, any>, options: AFSExecOptions): Promise<AFSExecResult>;
276
- private buildSimpleListView;
277
- private buildTreeView;
278
- private buildMetadataSuffix;
279
- private physicalPath?;
280
- initializePhysicalPath(): Promise<string>;
281
- cleanupPhysicalPath(): Promise<void>;
282
- }
283
- //#endregion
284
- //#region src/error.d.ts
285
- /**
286
- * Base error class for all AFS errors.
287
- */
288
- declare class AFSError extends Error {
289
- readonly code: string;
290
- constructor(message: string, code: string);
291
- }
292
- /**
293
- * Error thrown when attempting write operations on a readonly AFS or module.
294
- */
295
- declare class AFSReadonlyError extends AFSError {
296
- constructor(message: string);
297
- }
298
- //#endregion
299
- export { AFS, AFSAccessMode, AFSContext, AFSContextPreset, AFSContextPresetOptionAgent, AFSDeleteOptions, AFSDeleteResult, AFSEntry, AFSEntryMetadata, AFSError, AFSExecOptions, AFSExecResult, AFSListOptions, AFSListResult, AFSModule, AFSModuleClass, AFSModuleLoadParams, AFSOperationOptions, AFSOptions, AFSReadOptions, AFSReadResult, AFSReadonlyError, AFSRenameOptions, AFSRenameResult, AFSRoot, AFSRootEvents, AFSRootListOptions, AFSRootListResult, AFSRootSearchOptions, AFSRootSearchResult, AFSSearchOptions, AFSSearchResult, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult, accessModeSchema, afsEntrySchema };
300
- //# sourceMappingURL=index.d.cts.map
1
+ import { JSONSchema7 } from "./node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.cjs";
2
+ import { AFSExplainResult, KindSchema, MetaPathInfo, NodeConstraint, NodesConstraints, ValidationError, ValidationResult } from "./meta/type.cjs";
3
+ import { AFSAccessMode, AFSActionResult, AFSChangeListener, AFSChangeRecord, AFSDeleteOptions, AFSDeleteResult, AFSEntry, AFSEntryMetadata, AFSExecOptions, AFSExecResult, AFSExplainOptions, AFSListOptions, AFSListResult, AFSModule, AFSModuleClass, AFSModuleLoadParams, AFSOperationOptions, AFSReadOptions, AFSReadResult, AFSRenameOptions, AFSRenameResult, AFSRoot, AFSSearchOptions, AFSSearchResult, AFSStatOptions, AFSStatResult, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult, ActionSummary, AuthContext, CallbackServer, MountConfig, ProviderManifest, accessModeSchema, actionSummarySchema, afsEntrySchema } from "./type.cjs";
4
+ import { AFS, AFSOptions, MountInfo, MountOptions } from "./afs.cjs";
5
+ import { ActionCatalog, ActionDefinition, AggregatedCapabilities, CapabilitiesManifest, OperationsDeclaration, ToolDefinition } from "./capabilities/types.cjs";
6
+ import { AFSWorldMappingCapable, ExternalRef, MappingStatus, MutateAction, MutateResult, ProjectionContext, isWorldMappingCapable } from "./capabilities/world-mapping.cjs";
7
+ import { AFSError, AFSMountError, AFSNotFoundError, AFSReadonlyError, AFSValidationError } from "./error.cjs";
8
+ import { Kind, KindDefinition, KindError, KindResolver, createKindResolver, defaultKindResolver, defineKind, getInheritanceChain, resolveKindSchema } from "./meta/kind.cjs";
9
+ import { KINDS_SEGMENT, META_SEGMENT, getNodePathFromMetaPath, isKindsPath, isMetaPath, parseMetaPath } from "./meta/path.cjs";
10
+ import { combineValidationResults, validateNodes } from "./meta/validation.cjs";
11
+ import { WELL_KNOWN_KINDS, WELL_KNOWN_KINDS_MAP, afsDocument, afsExecutable, afsImage, afsLink, afsNode, commonMetaSchema, getWellKnownKind, isWellKnownKind } from "./meta/well-known-kinds.cjs";
12
+ import { AFSPathError, ParsedCanonicalPath, isCanonicalPath, normalizePath, parseCanonicalPath, toCanonicalPath, validateModuleName, validatePath } from "./path.cjs";
13
+ import { DeleteRouteHandler, ExecRouteHandler, ExplainRouteHandler, ListDecoratorOptions, ListHandlerResult, ListRouteHandler, ReadRouteHandler, RenameRouteHandler, RouteContext, RouteDefinition, RouteHandler, RouteMatch, RouteMetadata, RouteOperation, SearchRouteHandler, StatRouteHandler, WriteRouteHandler } from "./provider/types.cjs";
14
+ import { ProviderRouter } from "./provider/router.cjs";
15
+ import { AFSBaseProvider } from "./provider/base.cjs";
16
+ import { Actions, Delete, Exec, Explain, List, Meta, Read, Rename, Search, Stat, Write, clearRoutes, getRoutes } from "./provider/decorators.cjs";
17
+ import { ProviderFactory, ProviderRegistry } from "./registry.cjs";
18
+ export { AFS, AFSAccessMode, AFSActionResult, AFSBaseProvider, AFSChangeListener, AFSChangeRecord, AFSDeleteOptions, AFSDeleteResult, AFSEntry, AFSEntryMetadata, AFSError, AFSExecOptions, AFSExecResult, AFSExplainOptions, AFSExplainResult, AFSListOptions, AFSListResult, AFSModule, AFSModuleClass, AFSModuleLoadParams, AFSMountError, AFSNotFoundError, AFSOperationOptions, AFSOptions, AFSPathError, AFSReadOptions, AFSReadResult, AFSReadonlyError, AFSRenameOptions, AFSRenameResult, AFSRoot, AFSSearchOptions, AFSSearchResult, AFSStatOptions, AFSStatResult, AFSValidationError, AFSWorldMappingCapable, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult, ActionCatalog, ActionDefinition, ActionSummary, Actions, AggregatedCapabilities, AuthContext, CallbackServer, CapabilitiesManifest, Delete, DeleteRouteHandler, Exec, ExecRouteHandler, Explain, ExplainRouteHandler, ExternalRef, JSONSchema7, KINDS_SEGMENT, Kind, KindDefinition, KindError, KindResolver, KindSchema, List, ListDecoratorOptions, ListHandlerResult, ListRouteHandler, META_SEGMENT, MappingStatus, Meta, MetaPathInfo, MountConfig, MountInfo, MountOptions, MutateAction, MutateResult, NodeConstraint, NodesConstraints, OperationsDeclaration, ParsedCanonicalPath, ProjectionContext, ProviderFactory, ProviderManifest, ProviderRegistry, ProviderRouter, Read, ReadRouteHandler, Rename, RenameRouteHandler, RouteContext, RouteDefinition, RouteHandler, RouteMatch, RouteMetadata, RouteOperation, Search, SearchRouteHandler, Stat, StatRouteHandler, ToolDefinition, ValidationError, ValidationResult, WELL_KNOWN_KINDS, WELL_KNOWN_KINDS_MAP, Write, WriteRouteHandler, accessModeSchema, actionSummarySchema, afsDocument, afsEntrySchema, afsExecutable, afsImage, afsLink, afsNode, clearRoutes, combineValidationResults, commonMetaSchema, createKindResolver, defaultKindResolver, defineKind, getInheritanceChain, getNodePathFromMetaPath, getRoutes, getWellKnownKind, isCanonicalPath, isKindsPath, isMetaPath, isWellKnownKind, isWorldMappingCapable, normalizePath, parseCanonicalPath, parseMetaPath, resolveKindSchema, toCanonicalPath, validateModuleName, validateNodes, validatePath };
package/dist/index.d.mts CHANGED
@@ -1,300 +1,20 @@
1
- import { Emitter } from "strict-event-emitter";
2
- import { ZodType, z } from "zod";
3
-
4
- //#region src/type.d.ts
5
- /**
6
- * Access mode for AFS modules and root.
7
- * - "readonly": Only read operations are allowed (list, read, search)
8
- * - "readwrite": All operations are allowed
9
- */
10
- type AFSAccessMode = "readonly" | "readwrite";
11
- /**
12
- * Zod schema for access mode validation.
13
- * Can be reused across modules that support access mode configuration.
14
- */
15
- declare const accessModeSchema: z.ZodOptional<z.ZodEnum<["readonly", "readwrite"]>>;
16
- interface AFSOperationOptions {
17
- context?: any;
18
- }
19
- interface AFSListOptions extends AFSOperationOptions {
20
- filter?: {
21
- agentId?: string;
22
- userId?: string;
23
- sessionId?: string;
24
- before?: string;
25
- after?: string;
26
- };
27
- maxDepth?: number;
28
- limit?: number;
29
- orderBy?: [string, "asc" | "desc"][];
30
- maxChildren?: number;
31
- onOverflow?: "truncate";
32
- /**
33
- * Whether to disable .gitignore files when listing files.
34
- * @default false
35
- */
36
- disableGitignore?: boolean;
37
- /**
38
- * Glob pattern to filter entries by path.
39
- * Examples: "*.ts", "**\/*.js", "src/**\/*.{ts,tsx}"
40
- */
41
- pattern?: string;
42
- }
43
- interface AFSListResult {
44
- data: AFSEntry[];
45
- message?: string;
46
- }
47
- interface AFSSearchOptions extends AFSOperationOptions {
48
- limit?: number;
49
- caseSensitive?: boolean;
50
- }
51
- interface AFSSearchResult {
52
- data: AFSEntry[];
53
- message?: string;
54
- }
55
- interface AFSReadOptions extends AFSOperationOptions {
56
- filter?: AFSListOptions["filter"];
57
- }
58
- interface AFSReadResult {
59
- data?: AFSEntry;
60
- message?: string;
61
- }
62
- interface AFSDeleteOptions extends AFSOperationOptions {
63
- recursive?: boolean;
64
- }
65
- interface AFSDeleteResult {
66
- message?: string;
67
- }
68
- interface AFSRenameOptions extends AFSOperationOptions {
69
- overwrite?: boolean;
70
- }
71
- interface AFSRenameResult {
72
- message?: string;
73
- }
74
- interface AFSWriteOptions extends AFSOperationOptions {
75
- append?: boolean;
76
- }
77
- interface AFSWriteResult {
78
- data: AFSEntry;
79
- message?: string;
80
- context?: any;
81
- }
82
- interface AFSWriteEntryPayload extends Omit<AFSEntry, "id" | "path"> {}
83
- interface AFSExecOptions extends AFSOperationOptions {}
84
- interface AFSExecResult {
85
- data: Record<string, any>;
86
- }
87
- interface AFSModule {
88
- readonly name: string;
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;
103
- onMount?(root: AFSRoot): void;
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
- 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
- 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
- }
146
- type AFSRootEvents = {
147
- agentSucceed: [{
148
- agentId?: string;
149
- userId?: string;
150
- sessionId?: string;
151
- input: object;
152
- output: object;
153
- messages?: object[];
154
- }];
155
- historyCreated: [{
156
- entry: AFSEntry;
157
- }, options: AFSOperationOptions];
158
- };
159
- interface AFSRootListOptions extends AFSListOptions, AFSContextPreset {
160
- preset?: string;
161
- }
162
- interface AFSRootListResult extends Omit<AFSListResult, "data"> {
163
- data: any;
164
- }
165
- interface AFSRootSearchOptions extends AFSSearchOptions, AFSContextPreset {
166
- preset?: string;
167
- }
168
- interface AFSRootSearchResult extends Omit<AFSSearchResult, "data"> {
169
- data: any;
170
- }
171
- interface AFSRoot extends Emitter<AFSRootEvents>, AFSModule {
172
- list(path: string, options?: AFSRootListOptions): Promise<AFSRootListResult>;
173
- search(path: string, query: string, options: AFSRootSearchOptions): Promise<AFSRootSearchResult>;
174
- initializePhysicalPath(): Promise<string>;
175
- cleanupPhysicalPath(): Promise<void>;
176
- }
177
- interface AFSEntryMetadata extends Record<string, any> {
178
- execute?: {
179
- name: string;
180
- description?: string;
181
- inputSchema?: Record<string, any>;
182
- outputSchema?: Record<string, any>;
183
- };
184
- childrenCount?: number;
185
- childrenTruncated?: boolean;
186
- gitignored?: boolean;
187
- }
188
- interface AFSEntry<T = any> {
189
- id: string;
190
- createdAt?: Date;
191
- updatedAt?: Date;
192
- path: string;
193
- agentId?: string | null;
194
- userId?: string | null;
195
- sessionId?: string | null;
196
- summary?: string | null;
197
- description?: string | null;
198
- metadata?: AFSEntryMetadata | null;
199
- linkTo?: string | null;
200
- content?: T;
201
- }
202
- declare const afsEntrySchema: ZodType<AFSEntry>;
203
- interface AFSContextPreset {
204
- /**
205
- * The view template for presenting the search results.
206
- */
207
- view?: string;
208
- select?: AFSContextPresetOptionAgent<{
209
- path: string;
210
- query?: string;
211
- }, {
212
- data: string[];
213
- }>;
214
- per?: AFSContextPresetOptionAgent<{
215
- data: AFSEntry;
216
- }, {
217
- data: unknown;
218
- }>;
219
- dedupe?: AFSContextPresetOptionAgent<{
220
- data: unknown[];
221
- }, {
222
- data: unknown;
223
- }>;
224
- format?: "default" | "simple-list" | "tree" | AFSContextPresetOptionAgent<{
225
- data: unknown;
226
- }, {
227
- data: unknown;
228
- }>;
229
- }
230
- interface AFSContextPresetOptionAgent<I = any, O = any> {
231
- invoke(input: I, options?: any): Promise<O>;
232
- }
233
- interface AFSContext {
234
- search?: {
235
- presets?: Record<string, AFSContextPreset>;
236
- };
237
- list?: {
238
- presets?: Record<string, AFSContextPreset>;
239
- };
240
- }
241
- //#endregion
242
- //#region src/afs.d.ts
243
- interface AFSOptions {
244
- modules?: AFSModule[];
245
- context?: AFSContext;
246
- }
247
- declare class AFS extends Emitter<AFSRootEvents> implements AFSRoot {
248
- options: AFSOptions;
249
- name: string;
250
- constructor(options?: AFSOptions);
251
- private modules;
252
- /**
253
- * Check if write operations are allowed for the given module.
254
- * Throws AFSReadonlyError if not allowed.
255
- */
256
- private checkWritePermission;
257
- mount(module: AFSModule): this;
258
- listModules(): Promise<{
259
- name: string;
260
- path: string;
261
- description?: string;
262
- module: AFSModule;
263
- }[]>;
264
- list(path: string, options?: AFSRootListOptions): Promise<AFSRootListResult>;
265
- private _list;
266
- read(path: string, _options?: AFSReadOptions): Promise<AFSReadResult>;
267
- write(path: string, content: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<AFSWriteResult>;
268
- delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
269
- rename(oldPath: string, newPath: string, options?: AFSRenameOptions): Promise<AFSRenameResult>;
270
- search(path: string, query: string, options?: AFSRootSearchOptions): Promise<AFSRootSearchResult>;
271
- private processWithPreset;
272
- private _select;
273
- private _search;
274
- private findModules;
275
- exec(path: string, args: Record<string, any>, options: AFSExecOptions): Promise<AFSExecResult>;
276
- private buildSimpleListView;
277
- private buildTreeView;
278
- private buildMetadataSuffix;
279
- private physicalPath?;
280
- initializePhysicalPath(): Promise<string>;
281
- cleanupPhysicalPath(): Promise<void>;
282
- }
283
- //#endregion
284
- //#region src/error.d.ts
285
- /**
286
- * Base error class for all AFS errors.
287
- */
288
- declare class AFSError extends Error {
289
- readonly code: string;
290
- constructor(message: string, code: string);
291
- }
292
- /**
293
- * Error thrown when attempting write operations on a readonly AFS or module.
294
- */
295
- declare class AFSReadonlyError extends AFSError {
296
- constructor(message: string);
297
- }
298
- //#endregion
299
- export { AFS, AFSAccessMode, AFSContext, AFSContextPreset, AFSContextPresetOptionAgent, AFSDeleteOptions, AFSDeleteResult, AFSEntry, AFSEntryMetadata, AFSError, AFSExecOptions, AFSExecResult, AFSListOptions, AFSListResult, AFSModule, AFSModuleClass, AFSModuleLoadParams, AFSOperationOptions, AFSOptions, AFSReadOptions, AFSReadResult, AFSReadonlyError, AFSRenameOptions, AFSRenameResult, AFSRoot, AFSRootEvents, AFSRootListOptions, AFSRootListResult, AFSRootSearchOptions, AFSRootSearchResult, AFSSearchOptions, AFSSearchResult, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult, accessModeSchema, afsEntrySchema };
300
- //# sourceMappingURL=index.d.mts.map
1
+ import { JSONSchema7 } from "./node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.mjs";
2
+ import { AFSExplainResult, KindSchema, MetaPathInfo, NodeConstraint, NodesConstraints, ValidationError, ValidationResult } from "./meta/type.mjs";
3
+ import { AFSAccessMode, AFSActionResult, AFSChangeListener, AFSChangeRecord, AFSDeleteOptions, AFSDeleteResult, AFSEntry, AFSEntryMetadata, AFSExecOptions, AFSExecResult, AFSExplainOptions, AFSListOptions, AFSListResult, AFSModule, AFSModuleClass, AFSModuleLoadParams, AFSOperationOptions, AFSReadOptions, AFSReadResult, AFSRenameOptions, AFSRenameResult, AFSRoot, AFSSearchOptions, AFSSearchResult, AFSStatOptions, AFSStatResult, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult, ActionSummary, AuthContext, CallbackServer, MountConfig, ProviderManifest, accessModeSchema, actionSummarySchema, afsEntrySchema } from "./type.mjs";
4
+ import { AFS, AFSOptions, MountInfo, MountOptions } from "./afs.mjs";
5
+ import { ActionCatalog, ActionDefinition, AggregatedCapabilities, CapabilitiesManifest, OperationsDeclaration, ToolDefinition } from "./capabilities/types.mjs";
6
+ import { AFSWorldMappingCapable, ExternalRef, MappingStatus, MutateAction, MutateResult, ProjectionContext, isWorldMappingCapable } from "./capabilities/world-mapping.mjs";
7
+ import "./capabilities/index.mjs";
8
+ import { AFSError, AFSMountError, AFSNotFoundError, AFSReadonlyError, AFSValidationError } from "./error.mjs";
9
+ import { Kind, KindDefinition, KindError, KindResolver, createKindResolver, defaultKindResolver, defineKind, getInheritanceChain, resolveKindSchema } from "./meta/kind.mjs";
10
+ import { KINDS_SEGMENT, META_SEGMENT, getNodePathFromMetaPath, isKindsPath, isMetaPath, parseMetaPath } from "./meta/path.mjs";
11
+ import { combineValidationResults, validateNodes } from "./meta/validation.mjs";
12
+ import { WELL_KNOWN_KINDS, WELL_KNOWN_KINDS_MAP, afsDocument, afsExecutable, afsImage, afsLink, afsNode, commonMetaSchema, getWellKnownKind, isWellKnownKind } from "./meta/well-known-kinds.mjs";
13
+ import { AFSPathError, ParsedCanonicalPath, isCanonicalPath, normalizePath, parseCanonicalPath, toCanonicalPath, validateModuleName, validatePath } from "./path.mjs";
14
+ import { DeleteRouteHandler, ExecRouteHandler, ExplainRouteHandler, ListDecoratorOptions, ListHandlerResult, ListRouteHandler, ReadRouteHandler, RenameRouteHandler, RouteContext, RouteDefinition, RouteHandler, RouteMatch, RouteMetadata, RouteOperation, SearchRouteHandler, StatRouteHandler, WriteRouteHandler } from "./provider/types.mjs";
15
+ import { ProviderRouter } from "./provider/router.mjs";
16
+ import { AFSBaseProvider } from "./provider/base.mjs";
17
+ import { Actions, Delete, Exec, Explain, List, Meta, Read, Rename, Search, Stat, Write, clearRoutes, getRoutes } from "./provider/decorators.mjs";
18
+ import "./provider/index.mjs";
19
+ import { ProviderFactory, ProviderRegistry } from "./registry.mjs";
20
+ export { AFS, AFSAccessMode, AFSActionResult, AFSBaseProvider, AFSChangeListener, AFSChangeRecord, AFSDeleteOptions, AFSDeleteResult, AFSEntry, AFSEntryMetadata, AFSError, AFSExecOptions, AFSExecResult, AFSExplainOptions, AFSExplainResult, AFSListOptions, AFSListResult, AFSModule, AFSModuleClass, AFSModuleLoadParams, AFSMountError, AFSNotFoundError, AFSOperationOptions, AFSOptions, AFSPathError, AFSReadOptions, AFSReadResult, AFSReadonlyError, AFSRenameOptions, AFSRenameResult, AFSRoot, AFSSearchOptions, AFSSearchResult, AFSStatOptions, AFSStatResult, AFSValidationError, AFSWorldMappingCapable, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult, ActionCatalog, ActionDefinition, ActionSummary, Actions, AggregatedCapabilities, AuthContext, CallbackServer, CapabilitiesManifest, Delete, DeleteRouteHandler, Exec, ExecRouteHandler, Explain, ExplainRouteHandler, ExternalRef, JSONSchema7, KINDS_SEGMENT, Kind, KindDefinition, KindError, KindResolver, KindSchema, List, ListDecoratorOptions, ListHandlerResult, ListRouteHandler, META_SEGMENT, MappingStatus, Meta, MetaPathInfo, MountConfig, MountInfo, MountOptions, MutateAction, MutateResult, NodeConstraint, NodesConstraints, OperationsDeclaration, ParsedCanonicalPath, ProjectionContext, ProviderFactory, ProviderManifest, ProviderRegistry, ProviderRouter, Read, ReadRouteHandler, Rename, RenameRouteHandler, RouteContext, RouteDefinition, RouteHandler, RouteMatch, RouteMetadata, RouteOperation, Search, SearchRouteHandler, Stat, StatRouteHandler, ToolDefinition, ValidationError, ValidationResult, WELL_KNOWN_KINDS, WELL_KNOWN_KINDS_MAP, Write, WriteRouteHandler, accessModeSchema, actionSummarySchema, afsDocument, afsEntrySchema, afsExecutable, afsImage, afsLink, afsNode, clearRoutes, combineValidationResults, commonMetaSchema, createKindResolver, defaultKindResolver, defineKind, getInheritanceChain, getNodePathFromMetaPath, getRoutes, getWellKnownKind, isCanonicalPath, isKindsPath, isMetaPath, isWellKnownKind, isWorldMappingCapable, normalizePath, parseCanonicalPath, parseMetaPath, resolveKindSchema, toCanonicalPath, validateModuleName, validateNodes, validatePath };