@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/afs.d.cts ADDED
@@ -0,0 +1,275 @@
1
+ import { AFSExplainResult } from "./meta/type.cjs";
2
+ import { AFSChangeListener, AFSDeleteOptions, AFSDeleteResult, AFSExecOptions, AFSExecResult, AFSExplainOptions, AFSListOptions, AFSListResult, AFSModule, AFSReadOptions, AFSReadResult, AFSRenameOptions, AFSRenameResult, AFSRoot, AFSSearchOptions, AFSSearchResult, AFSStatOptions, AFSStatResult, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult } from "./type.cjs";
3
+
4
+ //#region src/afs.d.ts
5
+ /**
6
+ * Information about a mounted module
7
+ */
8
+ interface MountInfo {
9
+ /** The namespace (null for default namespace) */
10
+ namespace: string | null;
11
+ /** The mount path within the namespace */
12
+ path: string;
13
+ /** The mounted module */
14
+ module: AFSModule;
15
+ }
16
+ /**
17
+ * Options for mounting a module
18
+ */
19
+ interface MountOptions {
20
+ /** Namespace to mount into (null/undefined for default namespace) */
21
+ namespace?: string | null;
22
+ /** Replace existing mount at the same path */
23
+ replace?: boolean;
24
+ }
25
+ interface AFSOptions {
26
+ modules?: AFSModule[];
27
+ onChange?: AFSChangeListener;
28
+ }
29
+ declare class AFS implements AFSRoot {
30
+ options: AFSOptions;
31
+ name: string;
32
+ /**
33
+ * Injectable method for loading and mounting a provider from a URI.
34
+ * Injected by CLI layer (afs-loader.ts) with full pipeline:
35
+ * 1. ProviderRegistry.createProvider({ uri, path, ...options }) → provider instance
36
+ * 2. afs.mount(provider, path)
37
+ *
38
+ * Used by root-level /.actions/mount action and registry mount action.
39
+ */
40
+ loadProvider?: (uri: string, path: string, options?: Record<string, unknown>) => Promise<void>;
41
+ /**
42
+ * Injectable callback for removing a provider's config on unmount.
43
+ * Injected by CLI layer (afs-loader.ts) for persistence sync.
44
+ */
45
+ unloadProvider?: (path: string, options?: Record<string, unknown>) => Promise<void>;
46
+ /**
47
+ * Injectable callback for updating a provider's options in the config file.
48
+ * Injected by CLI layer (afs-loader.ts) for persistence sync.
49
+ * Used by providers to persist runtime config changes (e.g., default model selection).
50
+ */
51
+ updateProviderConfig?: (mountPath: string, optionUpdates: Record<string, unknown>) => Promise<void>;
52
+ constructor(options?: AFSOptions);
53
+ /**
54
+ * Internal storage: Map<compositeKey, MountEntry>
55
+ * compositeKey = `${namespace ?? ""}:${path}`
56
+ */
57
+ private mounts;
58
+ /**
59
+ * Legacy compatibility: Map<path, AFSModule> for modules mounted via old API
60
+ * This is used internally by findModules for backward compatibility
61
+ */
62
+ private get modules();
63
+ /**
64
+ * Create composite key for mount storage
65
+ */
66
+ private makeKey;
67
+ /**
68
+ * Check if write operations are allowed for the given module.
69
+ * Throws AFSReadonlyError if not allowed.
70
+ */
71
+ /** Fire-and-forget change notification */
72
+ private notifyChange;
73
+ private checkWritePermission;
74
+ /**
75
+ * Check provider availability on mount.
76
+ * Validates that the provider can successfully respond to stat/read
77
+ * and list (if childrenCount indicates children exist).
78
+ *
79
+ * @throws AFSMountError if validation fails
80
+ */
81
+ private checkProviderOnMount;
82
+ /**
83
+ * Mount a module at a path in a namespace
84
+ *
85
+ * @param module - The module to mount
86
+ * @param path - The path to mount at (optional, defaults to /modules/{module.name} for backward compatibility)
87
+ * @param options - Mount options (namespace, replace)
88
+ */
89
+ mount(module: AFSModule, path?: string, options?: MountOptions): Promise<this>;
90
+ /**
91
+ * Get all mounts, optionally filtered by namespace
92
+ *
93
+ * @param namespace - Filter by namespace (undefined = all, null = default only)
94
+ */
95
+ getMounts(namespace?: string | null): MountInfo[];
96
+ /**
97
+ * Get all unique namespaces that have mounts
98
+ */
99
+ getNamespaces(): (string | null)[];
100
+ /**
101
+ * Unmount a module at a path in a namespace
102
+ *
103
+ * @param path - The path to unmount
104
+ * @param namespace - The namespace (undefined/null for default namespace)
105
+ * @returns true if unmounted, false if not found
106
+ */
107
+ unmount(path: string, namespace?: string | null): boolean;
108
+ /**
109
+ * Check if a path is mounted in a namespace
110
+ *
111
+ * @param path - The path to check
112
+ * @param namespace - The namespace (undefined/null for default namespace)
113
+ */
114
+ isMounted(path: string, namespace?: string | null): boolean;
115
+ listModules(): Promise<{
116
+ name: string;
117
+ path: string;
118
+ namespace: string | null;
119
+ description?: string;
120
+ module: AFSModule;
121
+ }[]>;
122
+ /**
123
+ * Parse a path and extract namespace if it's a canonical path
124
+ * Returns the namespace and the path within the namespace
125
+ */
126
+ private parsePathWithNamespace;
127
+ /**
128
+ * Find modules that can handle a path in a specific namespace
129
+ */
130
+ private findModulesInNamespace;
131
+ list(path: string, options?: AFSListOptions): Promise<AFSListResult>;
132
+ private _list;
133
+ /**
134
+ * Check if a path should skip auto-enrichment.
135
+ * Paths ending with /.meta or /.actions should not be enriched
136
+ * to avoid recursive fetches, but their children (e.g., /.meta/kinds)
137
+ * can still be enriched.
138
+ */
139
+ private shouldSkipEnrich;
140
+ /**
141
+ * Fetch actions for a path by listing path/.actions.
142
+ * Returns ActionSummary[] on success, [] on failure.
143
+ */
144
+ private fetchActions;
145
+ /**
146
+ * Fetch meta for a path by reading path/.meta.
147
+ * Returns the meta content on success, null on failure.
148
+ */
149
+ private fetchMeta;
150
+ /**
151
+ * Type for data that can be enriched (has path, optional actions, optional meta)
152
+ */
153
+ private enrichData;
154
+ read(path: string, _options?: AFSReadOptions): Promise<AFSReadResult>;
155
+ /**
156
+ * Check if a path is a virtual intermediate directory.
157
+ * Returns a read result if the path is a parent of one or more mount paths.
158
+ */
159
+ private resolveVirtualDirectory;
160
+ /**
161
+ * Aggregate capabilities from all mounted providers.
162
+ *
163
+ * For each provider:
164
+ * - Read /.meta/.capabilities
165
+ * - Merge tools with provider prefix and mount path prefix
166
+ * - Merge actions with mount path prefix on discovery.pathTemplate
167
+ * - Silently skip providers that fail or don't implement capabilities
168
+ */
169
+ private aggregateCapabilities;
170
+ write(path: string, content: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<AFSWriteResult>;
171
+ delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
172
+ rename(oldPath: string, newPath: string, options?: AFSRenameOptions): Promise<AFSRenameResult>;
173
+ search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;
174
+ private _search;
175
+ exec(path: string, args: Record<string, any>, options?: AFSExecOptions): Promise<AFSExecResult>;
176
+ /**
177
+ * Read a root-level action entry (/.actions/mount, /.actions/unmount).
178
+ * Returns the action entry with metadata including inputSchema.
179
+ */
180
+ private readRootAction;
181
+ /**
182
+ * Read root metadata (/.meta).
183
+ * Returns mounted providers list, root actions, and childrenCount.
184
+ */
185
+ private readRootMeta;
186
+ /**
187
+ * Read root actions directory (/.actions).
188
+ * Returns content with actions list.
189
+ */
190
+ private readRootActions;
191
+ /**
192
+ * Stat a root action path (/.actions or /.actions/{name}).
193
+ */
194
+ private statRootAction;
195
+ /**
196
+ * Stat a root meta path (/.meta or /.meta/{subpath}).
197
+ */
198
+ private statRootMeta;
199
+ /**
200
+ * List root-level actions (/.actions).
201
+ */
202
+ private listRootActions;
203
+ /**
204
+ * Handle root-level action execution (/.actions/*).
205
+ * Supports:
206
+ * - /.actions/mount: Load and mount a provider via loadProvider
207
+ * - /.actions/unmount: Unmount a provider at a given path
208
+ */
209
+ private execRootAction;
210
+ /**
211
+ * Execute root-level mount action.
212
+ * Validates input and delegates to loadProvider.
213
+ */
214
+ private execRootMountAction;
215
+ /**
216
+ * Execute root-level unmount action.
217
+ * Validates input and delegates to unmount().
218
+ */
219
+ private execRootUnmountAction;
220
+ /**
221
+ * Validate exec input args against inputSchema.
222
+ * Throws AFSValidationError if validation fails.
223
+ * Uses zod-from-json-schema for full JSON Schema validation.
224
+ */
225
+ private validateExecInput;
226
+ /**
227
+ * Get stat information for a path
228
+ *
229
+ * Resolution order:
230
+ * 1. Provider's stat() method (if implemented)
231
+ * 2. Fallback to read() - extracts stat data from AFSEntry
232
+ *
233
+ * This allows providers to implement only read() while stat() still works.
234
+ */
235
+ stat(path: string, options?: AFSStatOptions): Promise<AFSStatResult>;
236
+ /**
237
+ * Get human-readable explanation for a path
238
+ *
239
+ * Resolution order:
240
+ * 1. Provider's explain() method (if implemented)
241
+ * 2. Fallback to stat() - builds explanation from metadata
242
+ *
243
+ * This allows providers to skip implementing explain() while it still works.
244
+ */
245
+ explain(path: string, options?: AFSExplainOptions): Promise<AFSExplainResult>;
246
+ /**
247
+ * Format bytes to human-readable string
248
+ */
249
+ private buildVirtualDirExplain;
250
+ /**
251
+ * Explain root path ('/').
252
+ * Generates a complete navigation guide with 4 required sections.
253
+ */
254
+ private explainRoot;
255
+ /**
256
+ * Explain a root action path (/.actions or /.actions/{name}).
257
+ */
258
+ private explainRootAction;
259
+ /**
260
+ * Explain a root meta path (/.meta or /.meta/{subpath}).
261
+ */
262
+ private explainRootMeta;
263
+ /**
264
+ * Build explain markdown from stat data.
265
+ * Used by both the module-found fallback and the no-module safety net.
266
+ */
267
+ private buildExplainFromStat;
268
+ private formatBytes;
269
+ private physicalPath?;
270
+ initializePhysicalPath(): Promise<string>;
271
+ cleanupPhysicalPath(): Promise<void>;
272
+ }
273
+ //#endregion
274
+ export { AFS, AFSOptions, MountInfo, MountOptions };
275
+ //# sourceMappingURL=afs.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"afs.d.cts","names":[],"sources":["../src/afs.ts"],"mappings":";;;;;;;UA8HiB,SAAA;EAAS;EAExB,SAAA;EAIiB;EAFjB,IAAA;EAAA;EAEA,MAAA,EAAQ,SAAA;AAAA;;;AAMV;UAAiB,YAAA;;EAEf,SAAA;EAEO;EAAP,OAAA;AAAA;AAAA,UAYe,UAAA;EACf,OAAA,GAAU,SAAA;EACV,QAAA,GADmB,iBAAA;AAAA;AAAA,cAIR,GAAA,YAAe,OAAA;EA6BP,OAAA,EAAS,UAAA;EA5B5B,IAAA;EAJQ;AAGV;;;;;;;EAWE,YAAA,IAAgB,GAAA,UAAa,IAAA,UAAc,OAAA,GAAU,MAAA,sBAA4B,OAAA;EAehE;;;;EATjB,cAAA,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ExecResult, AFSExplainOptions, AFSListOptions, AFSListResult, AFSModule, AFSReadOptions, AFSReadResult, AFSRenameOptions, AFSRenameResult, AFSRoot, AFSSearchOptions, AFSSearchResult, AFSStatOptions, AFSStatResult, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult } from "./type.mjs";
3
+
4
+ //#region src/afs.d.ts
5
+ /**
6
+ * Information about a mounted module
7
+ */
8
+ interface MountInfo {
9
+ /** The namespace (null for default namespace) */
10
+ namespace: string | null;
11
+ /** The mount path within the namespace */
12
+ path: string;
13
+ /** The mounted module */
14
+ module: AFSModule;
15
+ }
16
+ /**
17
+ * Options for mounting a module
18
+ */
19
+ interface MountOptions {
20
+ /** Namespace to mount into (null/undefined for default namespace) */
21
+ namespace?: string | null;
22
+ /** Replace existing mount at the same path */
23
+ replace?: boolean;
24
+ }
25
+ interface AFSOptions {
26
+ modules?: AFSModule[];
27
+ onChange?: AFSChangeListener;
28
+ }
29
+ declare class AFS implements AFSRoot {
30
+ options: AFSOptions;
31
+ name: string;
32
+ /**
33
+ * Injectable method for loading and mounting a provider from a URI.
34
+ * Injected by CLI layer (afs-loader.ts) with full pipeline:
35
+ * 1. ProviderRegistry.createProvider({ uri, path, ...options }) → provider instance
36
+ * 2. afs.mount(provider, path)
37
+ *
38
+ * Used by root-level /.actions/mount action and registry mount action.
39
+ */
40
+ loadProvider?: (uri: string, path: string, options?: Record<string, unknown>) => Promise<void>;
41
+ /**
42
+ * Injectable callback for removing a provider's config on unmount.
43
+ * Injected by CLI layer (afs-loader.ts) for persistence sync.
44
+ */
45
+ unloadProvider?: (path: string, options?: Record<string, unknown>) => Promise<void>;
46
+ /**
47
+ * Injectable callback for updating a provider's options in the config file.
48
+ * Injected by CLI layer (afs-loader.ts) for persistence sync.
49
+ * Used by providers to persist runtime config changes (e.g., default model selection).
50
+ */
51
+ updateProviderConfig?: (mountPath: string, optionUpdates: Record<string, unknown>) => Promise<void>;
52
+ constructor(options?: AFSOptions);
53
+ /**
54
+ * Internal storage: Map<compositeKey, MountEntry>
55
+ * compositeKey = `${namespace ?? ""}:${path}`
56
+ */
57
+ private mounts;
58
+ /**
59
+ * Legacy compatibility: Map<path, AFSModule> for modules mounted via old API
60
+ * This is used internally by findModules for backward compatibility
61
+ */
62
+ private get modules();
63
+ /**
64
+ * Create composite key for mount storage
65
+ */
66
+ private makeKey;
67
+ /**
68
+ * Check if write operations are allowed for the given module.
69
+ * Throws AFSReadonlyError if not allowed.
70
+ */
71
+ /** Fire-and-forget change notification */
72
+ private notifyChange;
73
+ private checkWritePermission;
74
+ /**
75
+ * Check provider availability on mount.
76
+ * Validates that the provider can successfully respond to stat/read
77
+ * and list (if childrenCount indicates children exist).
78
+ *
79
+ * @throws AFSMountError if validation fails
80
+ */
81
+ private checkProviderOnMount;
82
+ /**
83
+ * Mount a module at a path in a namespace
84
+ *
85
+ * @param module - The module to mount
86
+ * @param path - The path to mount at (optional, defaults to /modules/{module.name} for backward compatibility)
87
+ * @param options - Mount options (namespace, replace)
88
+ */
89
+ mount(module: AFSModule, path?: string, options?: MountOptions): Promise<this>;
90
+ /**
91
+ * Get all mounts, optionally filtered by namespace
92
+ *
93
+ * @param namespace - Filter by namespace (undefined = all, null = default only)
94
+ */
95
+ getMounts(namespace?: string | null): MountInfo[];
96
+ /**
97
+ * Get all unique namespaces that have mounts
98
+ */
99
+ getNamespaces(): (string | null)[];
100
+ /**
101
+ * Unmount a module at a path in a namespace
102
+ *
103
+ * @param path - The path to unmount
104
+ * @param namespace - The namespace (undefined/null for default namespace)
105
+ * @returns true if unmounted, false if not found
106
+ */
107
+ unmount(path: string, namespace?: string | null): boolean;
108
+ /**
109
+ * Check if a path is mounted in a namespace
110
+ *
111
+ * @param path - The path to check
112
+ * @param namespace - The namespace (undefined/null for default namespace)
113
+ */
114
+ isMounted(path: string, namespace?: string | null): boolean;
115
+ listModules(): Promise<{
116
+ name: string;
117
+ path: string;
118
+ namespace: string | null;
119
+ description?: string;
120
+ module: AFSModule;
121
+ }[]>;
122
+ /**
123
+ * Parse a path and extract namespace if it's a canonical path
124
+ * Returns the namespace and the path within the namespace
125
+ */
126
+ private parsePathWithNamespace;
127
+ /**
128
+ * Find modules that can handle a path in a specific namespace
129
+ */
130
+ private findModulesInNamespace;
131
+ list(path: string, options?: AFSListOptions): Promise<AFSListResult>;
132
+ private _list;
133
+ /**
134
+ * Check if a path should skip auto-enrichment.
135
+ * Paths ending with /.meta or /.actions should not be enriched
136
+ * to avoid recursive fetches, but their children (e.g., /.meta/kinds)
137
+ * can still be enriched.
138
+ */
139
+ private shouldSkipEnrich;
140
+ /**
141
+ * Fetch actions for a path by listing path/.actions.
142
+ * Returns ActionSummary[] on success, [] on failure.
143
+ */
144
+ private fetchActions;
145
+ /**
146
+ * Fetch meta for a path by reading path/.meta.
147
+ * Returns the meta content on success, null on failure.
148
+ */
149
+ private fetchMeta;
150
+ /**
151
+ * Type for data that can be enriched (has path, optional actions, optional meta)
152
+ */
153
+ private enrichData;
154
+ read(path: string, _options?: AFSReadOptions): Promise<AFSReadResult>;
155
+ /**
156
+ * Check if a path is a virtual intermediate directory.
157
+ * Returns a read result if the path is a parent of one or more mount paths.
158
+ */
159
+ private resolveVirtualDirectory;
160
+ /**
161
+ * Aggregate capabilities from all mounted providers.
162
+ *
163
+ * For each provider:
164
+ * - Read /.meta/.capabilities
165
+ * - Merge tools with provider prefix and mount path prefix
166
+ * - Merge actions with mount path prefix on discovery.pathTemplate
167
+ * - Silently skip providers that fail or don't implement capabilities
168
+ */
169
+ private aggregateCapabilities;
170
+ write(path: string, content: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<AFSWriteResult>;
171
+ delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
172
+ rename(oldPath: string, newPath: string, options?: AFSRenameOptions): Promise<AFSRenameResult>;
173
+ search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;
174
+ private _search;
175
+ exec(path: string, args: Record<string, any>, options?: AFSExecOptions): Promise<AFSExecResult>;
176
+ /**
177
+ * Read a root-level action entry (/.actions/mount, /.actions/unmount).
178
+ * Returns the action entry with metadata including inputSchema.
179
+ */
180
+ private readRootAction;
181
+ /**
182
+ * Read root metadata (/.meta).
183
+ * Returns mounted providers list, root actions, and childrenCount.
184
+ */
185
+ private readRootMeta;
186
+ /**
187
+ * Read root actions directory (/.actions).
188
+ * Returns content with actions list.
189
+ */
190
+ private readRootActions;
191
+ /**
192
+ * Stat a root action path (/.actions or /.actions/{name}).
193
+ */
194
+ private statRootAction;
195
+ /**
196
+ * Stat a root meta path (/.meta or /.meta/{subpath}).
197
+ */
198
+ private statRootMeta;
199
+ /**
200
+ * List root-level actions (/.actions).
201
+ */
202
+ private listRootActions;
203
+ /**
204
+ * Handle root-level action execution (/.actions/*).
205
+ * Supports:
206
+ * - /.actions/mount: Load and mount a provider via loadProvider
207
+ * - /.actions/unmount: Unmount a provider at a given path
208
+ */
209
+ private execRootAction;
210
+ /**
211
+ * Execute root-level mount action.
212
+ * Validates input and delegates to loadProvider.
213
+ */
214
+ private execRootMountAction;
215
+ /**
216
+ * Execute root-level unmount action.
217
+ * Validates input and delegates to unmount().
218
+ */
219
+ private execRootUnmountAction;
220
+ /**
221
+ * Validate exec input args against inputSchema.
222
+ * Throws AFSValidationError if validation fails.
223
+ * Uses zod-from-json-schema for full JSON Schema validation.
224
+ */
225
+ private validateExecInput;
226
+ /**
227
+ * Get stat information for a path
228
+ *
229
+ * Resolution order:
230
+ * 1. Provider's stat() method (if implemented)
231
+ * 2. Fallback to read() - extracts stat data from AFSEntry
232
+ *
233
+ * This allows providers to implement only read() while stat() still works.
234
+ */
235
+ stat(path: string, options?: AFSStatOptions): Promise<AFSStatResult>;
236
+ /**
237
+ * Get human-readable explanation for a path
238
+ *
239
+ * Resolution order:
240
+ * 1. Provider's explain() method (if implemented)
241
+ * 2. Fallback to stat() - builds explanation from metadata
242
+ *
243
+ * This allows providers to skip implementing explain() while it still works.
244
+ */
245
+ explain(path: string, options?: AFSExplainOptions): Promise<AFSExplainResult>;
246
+ /**
247
+ * Format bytes to human-readable string
248
+ */
249
+ private buildVirtualDirExplain;
250
+ /**
251
+ * Explain root path ('/').
252
+ * Generates a complete navigation guide with 4 required sections.
253
+ */
254
+ private explainRoot;
255
+ /**
256
+ * Explain a root action path (/.actions or /.actions/{name}).
257
+ */
258
+ private explainRootAction;
259
+ /**
260
+ * Explain a root meta path (/.meta or /.meta/{subpath}).
261
+ */
262
+ private explainRootMeta;
263
+ /**
264
+ * Build explain markdown from stat data.
265
+ * Used by both the module-found fallback and the no-module safety net.
266
+ */
267
+ private buildExplainFromStat;
268
+ private formatBytes;
269
+ private physicalPath?;
270
+ initializePhysicalPath(): Promise<string>;
271
+ cleanupPhysicalPath(): Promise<void>;
272
+ }
273
+ //#endregion
274
+ export { AFS, AFSOptions, MountInfo, MountOptions };
275
+ //# sourceMappingURL=afs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"afs.d.mts","names":[],"sources":["../src/afs.ts"],"mappings":";;;;;;;UA8HiB,SAAA;EAAS;EAExB,SAAA;EAIiB;EAFjB,IAAA;EAAA;EAEA,MAAA,EAAQ,SAAA;AAAA;;;AAMV;UAAiB,YAAA;;EAEf,SAAA;EAEO;EAAP,OAAA;AAAA;AAAA,UAYe,UAAA;EACf,OAAA,GAAU,SAAA;EACV,QAAA,GADmB,iBAAA;AAAA;AAAA,cAIR,GAAA,YAAe,OAAA;EA6BP,OAAA,EAAS,UAAA;EA5B5B,IAAA;EAJQ;AAGV;;;;;;;EAWE,YAAA,IAAgB,GAAA,UAAa,IAAA,UAAc,OAAA,GAAU,MAAA,sBAA4B,OAAA;EAehE;;;;EATjB,cAAA,IAAkB,IAAA,UAAc,OAAA,GAAU,MAAA,sBAA4B,OAAA;EAgJC;;;;;EAzIvE,oBAAA,IACE,SAAA,UACA,aAAA,EAAe,MAAA,sBACZ,OAAA;cAEc,OAAA,GAAS,UAAA;EA6pBQ;;;;EAAA,QAlpB5B,MAAA;EA21BG;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