@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.
- package/LICENSE.md +17 -84
- package/README.md +4 -13
- package/dist/_virtual/rolldown_runtime.mjs +7 -0
- package/dist/afs.cjs +1330 -0
- package/dist/afs.d.cts +275 -0
- package/dist/afs.d.cts.map +1 -0
- package/dist/afs.d.mts +275 -0
- package/dist/afs.d.mts.map +1 -0
- package/dist/afs.mjs +1331 -0
- package/dist/afs.mjs.map +1 -0
- package/dist/capabilities/index.d.mts +2 -0
- package/dist/capabilities/types.d.cts +100 -0
- package/dist/capabilities/types.d.cts.map +1 -0
- package/dist/capabilities/types.d.mts +100 -0
- package/dist/capabilities/types.d.mts.map +1 -0
- package/dist/capabilities/world-mapping.cjs +20 -0
- package/dist/capabilities/world-mapping.d.cts +139 -0
- package/dist/capabilities/world-mapping.d.cts.map +1 -0
- package/dist/capabilities/world-mapping.d.mts +139 -0
- package/dist/capabilities/world-mapping.d.mts.map +1 -0
- package/dist/capabilities/world-mapping.mjs +20 -0
- package/dist/capabilities/world-mapping.mjs.map +1 -0
- package/dist/error.cjs +63 -0
- package/dist/error.d.cts +39 -0
- package/dist/error.d.cts.map +1 -0
- package/dist/error.d.mts +39 -0
- package/dist/error.d.mts.map +1 -0
- package/dist/error.mjs +59 -0
- package/dist/error.mjs.map +1 -0
- package/dist/index.cjs +72 -345
- package/dist/index.d.cts +18 -300
- package/dist/index.d.mts +20 -300
- package/dist/index.mjs +16 -342
- package/dist/loader/index.cjs +110 -0
- package/dist/loader/index.d.cts +48 -0
- package/dist/loader/index.d.cts.map +1 -0
- package/dist/loader/index.d.mts +48 -0
- package/dist/loader/index.d.mts.map +1 -0
- package/dist/loader/index.mjs +110 -0
- package/dist/loader/index.mjs.map +1 -0
- package/dist/meta/index.cjs +4 -0
- package/dist/meta/index.mjs +6 -0
- package/dist/meta/kind.cjs +161 -0
- package/dist/meta/kind.d.cts +134 -0
- package/dist/meta/kind.d.cts.map +1 -0
- package/dist/meta/kind.d.mts +134 -0
- package/dist/meta/kind.d.mts.map +1 -0
- package/dist/meta/kind.mjs +157 -0
- package/dist/meta/kind.mjs.map +1 -0
- package/dist/meta/path.cjs +116 -0
- package/dist/meta/path.d.cts +43 -0
- package/dist/meta/path.d.cts.map +1 -0
- package/dist/meta/path.d.mts +43 -0
- package/dist/meta/path.d.mts.map +1 -0
- package/dist/meta/path.mjs +112 -0
- package/dist/meta/path.mjs.map +1 -0
- package/dist/meta/type.d.cts +96 -0
- package/dist/meta/type.d.cts.map +1 -0
- package/dist/meta/type.d.mts +96 -0
- package/dist/meta/type.d.mts.map +1 -0
- package/dist/meta/validation.cjs +77 -0
- package/dist/meta/validation.d.cts +19 -0
- package/dist/meta/validation.d.cts.map +1 -0
- package/dist/meta/validation.d.mts +19 -0
- package/dist/meta/validation.d.mts.map +1 -0
- package/dist/meta/validation.mjs +77 -0
- package/dist/meta/validation.mjs.map +1 -0
- package/dist/meta/well-known-kinds.cjs +228 -0
- package/dist/meta/well-known-kinds.d.cts +52 -0
- package/dist/meta/well-known-kinds.d.cts.map +1 -0
- package/dist/meta/well-known-kinds.d.mts +52 -0
- package/dist/meta/well-known-kinds.d.mts.map +1 -0
- package/dist/meta/well-known-kinds.mjs +219 -0
- package/dist/meta/well-known-kinds.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.cts +141 -0
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.mts +141 -0
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.mts.map +1 -0
- package/dist/path.cjs +255 -0
- package/dist/path.d.cts +93 -0
- package/dist/path.d.cts.map +1 -0
- package/dist/path.d.mts +93 -0
- package/dist/path.d.mts.map +1 -0
- package/dist/path.mjs +249 -0
- package/dist/path.mjs.map +1 -0
- package/dist/provider/base.cjs +425 -0
- package/dist/provider/base.d.cts +175 -0
- package/dist/provider/base.d.cts.map +1 -0
- package/dist/provider/base.d.mts +175 -0
- package/dist/provider/base.d.mts.map +1 -0
- package/dist/provider/base.mjs +426 -0
- package/dist/provider/base.mjs.map +1 -0
- package/dist/provider/decorators.cjs +268 -0
- package/dist/provider/decorators.d.cts +244 -0
- package/dist/provider/decorators.d.cts.map +1 -0
- package/dist/provider/decorators.d.mts +244 -0
- package/dist/provider/decorators.d.mts.map +1 -0
- package/dist/provider/decorators.mjs +256 -0
- package/dist/provider/decorators.mjs.map +1 -0
- package/dist/provider/index.cjs +19 -0
- package/dist/provider/index.d.cts +5 -0
- package/dist/provider/index.d.mts +5 -0
- package/dist/provider/index.mjs +5 -0
- package/dist/provider/router.cjs +185 -0
- package/dist/provider/router.d.cts +50 -0
- package/dist/provider/router.d.cts.map +1 -0
- package/dist/provider/router.d.mts +50 -0
- package/dist/provider/router.d.mts.map +1 -0
- package/dist/provider/router.mjs +185 -0
- package/dist/provider/router.mjs.map +1 -0
- package/dist/provider/types.d.cts +113 -0
- package/dist/provider/types.d.cts.map +1 -0
- package/dist/provider/types.d.mts +113 -0
- package/dist/provider/types.d.mts.map +1 -0
- package/dist/registry.cjs +358 -0
- package/dist/registry.d.cts +96 -0
- package/dist/registry.d.cts.map +1 -0
- package/dist/registry.d.mts +96 -0
- package/dist/registry.d.mts.map +1 -0
- package/dist/registry.mjs +360 -0
- package/dist/registry.mjs.map +1 -0
- package/dist/type.cjs +34 -0
- package/dist/type.d.cts +420 -0
- package/dist/type.d.cts.map +1 -0
- package/dist/type.d.mts +420 -0
- package/dist/type.d.mts.map +1 -0
- package/dist/type.mjs +33 -0
- package/dist/type.mjs.map +1 -0
- package/dist/utils/camelize.d.cts.map +1 -1
- package/dist/utils/camelize.d.mts.map +1 -1
- package/dist/utils/schema.cjs +129 -0
- package/dist/utils/schema.d.cts +65 -0
- package/dist/utils/schema.d.cts.map +1 -0
- package/dist/utils/schema.d.mts +65 -0
- package/dist/utils/schema.d.mts.map +1 -0
- package/dist/utils/schema.mjs +124 -0
- package/dist/utils/schema.mjs.map +1 -0
- package/dist/utils/type-utils.d.cts.map +1 -1
- package/dist/utils/type-utils.d.mts.map +1 -1
- package/dist/utils/uri-template.cjs +123 -0
- package/dist/utils/uri-template.d.cts +48 -0
- package/dist/utils/uri-template.d.cts.map +1 -0
- package/dist/utils/uri-template.d.mts +48 -0
- package/dist/utils/uri-template.d.mts.map +1 -0
- package/dist/utils/uri-template.mjs +120 -0
- package/dist/utils/uri-template.mjs.map +1 -0
- package/dist/utils/uri.cjs +49 -0
- package/dist/utils/uri.d.cts +34 -0
- package/dist/utils/uri.d.cts.map +1 -0
- package/dist/utils/uri.d.mts +34 -0
- package/dist/utils/uri.d.mts.map +1 -0
- package/dist/utils/uri.mjs +49 -0
- package/dist/utils/uri.mjs.map +1 -0
- package/dist/utils/zod.cjs +6 -8
- package/dist/utils/zod.d.cts +2 -2
- package/dist/utils/zod.d.cts.map +1 -1
- package/dist/utils/zod.d.mts +2 -2
- package/dist/utils/zod.d.mts.map +1 -1
- package/dist/utils/zod.mjs +6 -8
- package/dist/utils/zod.mjs.map +1 -1
- package/package.json +27 -4
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/afs.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"afs.mjs","names":["statResult","lines","actions","action"],"sources":["../src/afs.ts"],"sourcesContent":["import { v7 } from \"@aigne/uuid\";\nimport { joinURL } from \"ufo\";\nimport type {\n ActionCatalog,\n AggregatedCapabilities,\n CapabilitiesManifest,\n OperationsDeclaration,\n ToolDefinition,\n} from \"./capabilities/types.js\";\nimport { AFSMountError, AFSNotFoundError, AFSReadonlyError, AFSValidationError } from \"./error.js\";\nimport { isCanonicalPath, parseCanonicalPath, validateModuleName, validatePath } from \"./path.js\";\nimport type {\n ActionSummary,\n AFSDeleteOptions,\n AFSDeleteResult,\n AFSEntry,\n AFSExecOptions,\n AFSExecResult,\n AFSExplainOptions,\n AFSExplainResult,\n AFSListOptions,\n AFSListResult,\n AFSModule,\n AFSReadOptions,\n AFSReadResult,\n AFSRenameOptions,\n AFSRenameResult,\n AFSRoot,\n AFSSearchOptions,\n AFSSearchResult,\n AFSStatOptions,\n AFSStatResult,\n AFSWriteEntryPayload,\n AFSWriteOptions,\n AFSWriteResult,\n} from \"./type.js\";\n\nconst DEFAULT_MAX_DEPTH = 1;\n\nconst MODULES_ROOT_DIR = \"/modules\";\n\n/**\n * Default timeout for mount check operations (10 seconds)\n */\nconst DEFAULT_MOUNT_TIMEOUT = 10000;\n\n/**\n * Execute a promise with a timeout.\n * Throws an error if the promise does not resolve within the timeout.\n */\nasync function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> {\n let timeoutId: ReturnType<typeof setTimeout>;\n\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => reject(new Error(`Timeout after ${ms}ms`)), ms);\n });\n\n try {\n return await Promise.race([promise, timeoutPromise]);\n } finally {\n clearTimeout(timeoutId!);\n }\n}\n\n/**\n * Get the timeout value for a provider.\n * Returns provider.timeout if set, otherwise DEFAULT_MOUNT_TIMEOUT.\n */\nfunction getTimeout(provider: AFSModule): number {\n return provider.timeout ?? DEFAULT_MOUNT_TIMEOUT;\n}\n\n/**\n * Get error message from an error, handling timeout specially.\n */\nfunction getMountErrorMessage(err: unknown, timeout: number): string {\n if (err instanceof Error) {\n if (err.message.includes(\"Timeout\")) {\n return `Timeout after ${timeout}ms`;\n }\n return err.message;\n }\n return String(err);\n}\n\n/**\n * Characters forbidden in namespace names (security-sensitive)\n */\nconst NAMESPACE_FORBIDDEN_CHARS = [\n \"/\", // Path separator\n \"\\\\\", // Windows path separator\n \":\", // Namespace separator (only one allowed)\n \";\", // Shell metachar\n \"|\", // Shell pipe\n \"&\", // Shell background\n \"`\", // Shell command substitution\n \"$\", // Shell variable\n \"(\", // Shell subshell\n \")\", // Shell subshell\n \">\", // Shell redirect\n \"<\", // Shell redirect\n \"\\n\", // Newline\n \"\\r\", // Carriage return\n \"\\t\", // Tab\n \"\\x00\", // NUL\n];\n\n/**\n * Validate a namespace name for mount operations\n * @throws Error if namespace is invalid\n */\nfunction validateNamespaceName(namespace: string): void {\n if (namespace.trim() === \"\") {\n throw new Error(\"Namespace cannot be empty or whitespace-only\");\n }\n\n for (const char of NAMESPACE_FORBIDDEN_CHARS) {\n if (namespace.includes(char)) {\n throw new Error(`Namespace contains forbidden character: '${char}'`);\n }\n }\n}\n\n/**\n * Information about a mounted module\n */\nexport interface MountInfo {\n /** The namespace (null for default namespace) */\n namespace: string | null;\n /** The mount path within the namespace */\n path: string;\n /** The mounted module */\n module: AFSModule;\n}\n\n/**\n * Options for mounting a module\n */\nexport interface MountOptions {\n /** Namespace to mount into (null/undefined for default namespace) */\n namespace?: string | null;\n /** Replace existing mount at the same path */\n replace?: boolean;\n}\n\n/**\n * Internal mount entry with composite key\n */\ninterface MountEntry {\n namespace: string | null;\n path: string;\n module: AFSModule;\n}\n\nexport interface AFSOptions {\n modules?: AFSModule[];\n onChange?: import(\"./type.js\").AFSChangeListener;\n}\n\nexport class AFS implements AFSRoot {\n name: string = \"AFSRoot\";\n\n /**\n * Injectable method for loading and mounting a provider from a URI.\n * Injected by CLI layer (afs-loader.ts) with full pipeline:\n * 1. ProviderRegistry.createProvider({ uri, path, ...options }) → provider instance\n * 2. afs.mount(provider, path)\n *\n * Used by root-level /.actions/mount action and registry mount action.\n */\n loadProvider?: (uri: string, path: string, options?: Record<string, unknown>) => Promise<void>;\n\n /**\n * Injectable callback for removing a provider's config on unmount.\n * Injected by CLI layer (afs-loader.ts) for persistence sync.\n */\n unloadProvider?: (path: string, options?: Record<string, unknown>) => Promise<void>;\n\n /**\n * Injectable callback for updating a provider's options in the config file.\n * Injected by CLI layer (afs-loader.ts) for persistence sync.\n * Used by providers to persist runtime config changes (e.g., default model selection).\n */\n updateProviderConfig?: (\n mountPath: string,\n optionUpdates: Record<string, unknown>,\n ) => Promise<void>;\n\n constructor(public options: AFSOptions = {}) {\n for (const module of options?.modules ?? []) {\n // Legacy: mount with module name as path\n this.mount(module, joinURL(MODULES_ROOT_DIR, module.name));\n }\n }\n\n /**\n * Internal storage: Map<compositeKey, MountEntry>\n * compositeKey = `${namespace ?? \"\"}:${path}`\n */\n private mounts = new Map<string, MountEntry>();\n\n /**\n * Legacy compatibility: Map<path, AFSModule> for modules mounted via old API\n * This is used internally by findModules for backward compatibility\n */\n private get modules(): Map<string, AFSModule> {\n const map = new Map<string, AFSModule>();\n for (const entry of this.mounts.values()) {\n if (entry.namespace === null) {\n map.set(entry.path, entry.module);\n }\n }\n return map;\n }\n\n /**\n * Create composite key for mount storage\n */\n private makeKey(namespace: string | null, path: string): string {\n return `${namespace ?? \"\"}:${path}`;\n }\n\n /**\n * Check if write operations are allowed for the given module.\n * Throws AFSReadonlyError if not allowed.\n */\n /** Fire-and-forget change notification */\n private notifyChange(record: import(\"./type.js\").AFSChangeRecord): void {\n try {\n this.options.onChange?.(record);\n } catch {\n // INV-CE-2: listener failure MUST NOT affect AFS operation\n }\n }\n\n private checkWritePermission(module: AFSModule, operation: string, path: string): void {\n // Module-level readonly (undefined means readonly by default)\n if (module.accessMode !== \"readwrite\") {\n throw new AFSReadonlyError(\n `Module '${module.name}' is readonly, cannot perform ${operation} to ${path}`,\n );\n }\n }\n\n /**\n * Check provider availability on mount.\n * Validates that the provider can successfully respond to stat/read\n * and list (if childrenCount indicates children exist).\n *\n * @throws AFSMountError if validation fails\n */\n private async checkProviderOnMount(provider: AFSModule): Promise<void> {\n const timeout = getTimeout(provider);\n const name = provider.name;\n\n // Step 1: Try stat or read\n let rootData: { path: string; meta?: Record<string, unknown> | null } | undefined;\n\n if (provider.stat) {\n try {\n const result = await withTimeout(provider.stat(\"/\"), timeout);\n rootData = result.data;\n } catch (err) {\n throw new AFSMountError(name, \"stat\", getMountErrorMessage(err, timeout));\n }\n } else if (provider.read) {\n try {\n const result = await withTimeout(provider.read(\"/\"), timeout);\n if (result.data) {\n rootData = {\n path: result.data.path,\n meta: result.data.meta ?? undefined,\n };\n }\n } catch (err) {\n throw new AFSMountError(name, \"read\", getMountErrorMessage(err, timeout));\n }\n } else {\n throw new AFSMountError(name, \"read\", \"Provider has no stat or read method\");\n }\n\n // Step 2: Validate data is not undefined\n if (!rootData) {\n const step = provider.stat ? \"stat\" : \"read\";\n throw new AFSMountError(name, step, \"Root path returned undefined data\");\n }\n\n // Step 3: If childrenCount indicates children, validate list\n const childrenCount = rootData.meta?.childrenCount as number | undefined;\n const needsListCheck =\n childrenCount === -1 || (typeof childrenCount === \"number\" && childrenCount > 0);\n\n if (needsListCheck) {\n if (!provider.list) {\n throw new AFSMountError(name, \"list\", \"Provider has childrenCount but no list method\");\n }\n\n try {\n const listResult = await withTimeout(provider.list(\"/\"), timeout);\n if (!listResult.data || listResult.data.length === 0) {\n throw new AFSMountError(\n name,\n \"list\",\n \"childrenCount indicates children but list returned empty\",\n );\n }\n } catch (err) {\n if (err instanceof AFSMountError) throw err;\n throw new AFSMountError(name, \"list\", getMountErrorMessage(err, timeout));\n }\n }\n }\n\n /**\n * Mount a module at a path in a namespace\n *\n * @param module - The module to mount\n * @param path - The path to mount at (optional, defaults to /modules/{module.name} for backward compatibility)\n * @param options - Mount options (namespace, replace)\n */\n async mount(module: AFSModule, path?: string, options?: MountOptions): Promise<this> {\n // Validate module name\n validateModuleName(module.name);\n\n // If path not provided, use legacy path pattern for backward compatibility\n const mountPath = path ?? joinURL(MODULES_ROOT_DIR, module.name);\n\n // Validate and normalize path\n const normalizedPath = validatePath(mountPath);\n\n // Determine namespace (null for default, or explicit string)\n const namespace = options?.namespace === undefined ? null : options.namespace;\n\n // Validate namespace if provided\n if (namespace !== null) {\n if (namespace === \"\") {\n throw new Error(\"Namespace cannot be empty or whitespace-only\");\n }\n validateNamespaceName(namespace);\n }\n\n const key = this.makeKey(namespace, normalizedPath);\n\n // Check for exact path conflict\n if (this.mounts.has(key)) {\n if (options?.replace) {\n // Replace existing mount\n this.mounts.delete(key);\n } else {\n throw new Error(\n `Mount conflict: path '${normalizedPath}' already mounted in namespace '${namespace ?? \"default\"}'`,\n );\n }\n }\n\n // Check for parent-child path conflicts within the same namespace\n for (const entry of this.mounts.values()) {\n if (entry.namespace !== namespace) continue;\n\n const existingPath = entry.path;\n\n // Root \"/\" conflicts with everything\n if (normalizedPath === \"/\" || existingPath === \"/\") {\n throw new Error(\n `Mount conflict: path '${normalizedPath}' conflicts with existing mount '${existingPath}' in namespace '${namespace ?? \"default\"}'`,\n );\n }\n\n // Check if new path is parent of existing (or same)\n if (\n existingPath.startsWith(normalizedPath) &&\n (existingPath === normalizedPath ||\n existingPath.length === normalizedPath.length ||\n existingPath[normalizedPath.length] === \"/\")\n ) {\n throw new Error(\n `Mount conflict: path '${normalizedPath}' conflicts with existing mount '${existingPath}' in namespace '${namespace ?? \"default\"}'`,\n );\n }\n\n // Check if existing path is parent of new (or same)\n if (\n normalizedPath.startsWith(existingPath) &&\n (normalizedPath === existingPath ||\n normalizedPath.length === existingPath.length ||\n normalizedPath[existingPath.length] === \"/\")\n ) {\n throw new Error(\n `Mount conflict: path '${normalizedPath}' conflicts with existing mount '${existingPath}' in namespace '${namespace ?? \"default\"}'`,\n );\n }\n }\n\n // Check provider availability before registering\n await this.checkProviderOnMount(module);\n\n // Store mount\n this.mounts.set(key, {\n namespace,\n path: normalizedPath,\n module,\n });\n\n module.onMount?.(this, normalizedPath);\n this.notifyChange({\n kind: \"mount\",\n path: normalizedPath,\n moduleName: module.name,\n namespace,\n timestamp: Date.now(),\n });\n return this;\n }\n\n /**\n * Get all mounts, optionally filtered by namespace\n *\n * @param namespace - Filter by namespace (undefined = all, null = default only)\n */\n getMounts(namespace?: string | null): MountInfo[] {\n const result: MountInfo[] = [];\n\n for (const entry of this.mounts.values()) {\n if (namespace === undefined || entry.namespace === namespace) {\n result.push({\n namespace: entry.namespace,\n path: entry.path,\n module: entry.module,\n });\n }\n }\n\n return result;\n }\n\n /**\n * Get all unique namespaces that have mounts\n */\n getNamespaces(): (string | null)[] {\n const namespaces = new Set<string | null>();\n for (const entry of this.mounts.values()) {\n namespaces.add(entry.namespace);\n }\n return Array.from(namespaces);\n }\n\n /**\n * Unmount a module at a path in a namespace\n *\n * @param path - The path to unmount\n * @param namespace - The namespace (undefined/null for default namespace)\n * @returns true if unmounted, false if not found\n */\n unmount(path: string, namespace?: string | null): boolean {\n const normalizedPath = validatePath(path);\n const ns = namespace === undefined ? null : namespace;\n const key = this.makeKey(ns, normalizedPath);\n\n const entry = this.mounts.get(key);\n if (entry) {\n this.mounts.delete(key);\n this.notifyChange({\n kind: \"unmount\",\n path: normalizedPath,\n moduleName: entry.module.name,\n namespace: entry.namespace,\n timestamp: Date.now(),\n });\n return true;\n }\n return false;\n }\n\n /**\n * Check if a path is mounted in a namespace\n *\n * @param path - The path to check\n * @param namespace - The namespace (undefined/null for default namespace)\n */\n isMounted(path: string, namespace?: string | null): boolean {\n const normalizedPath = validatePath(path);\n const ns = namespace === undefined ? null : namespace;\n const key = this.makeKey(ns, normalizedPath);\n return this.mounts.has(key);\n }\n\n async listModules(): Promise<\n {\n name: string;\n path: string;\n namespace: string | null;\n description?: string;\n module: AFSModule;\n }[]\n > {\n return Array.from(this.mounts.values()).map((entry) => ({\n path: entry.path,\n namespace: entry.namespace,\n name: entry.module.name,\n description: entry.module.description,\n module: entry.module,\n }));\n }\n\n /**\n * Parse a path and extract namespace if it's a canonical path\n * Returns the namespace and the path within the namespace\n */\n private parsePathWithNamespace(inputPath: string): { namespace: string | null; path: string } {\n if (isCanonicalPath(inputPath)) {\n const parsed = parseCanonicalPath(inputPath);\n return { namespace: parsed.namespace, path: parsed.path };\n }\n // Non-canonical path defaults to default namespace\n return { namespace: null, path: validatePath(inputPath) };\n }\n\n /**\n * Find modules that can handle a path in a specific namespace\n */\n private findModulesInNamespace(\n path: string,\n namespace: string | null,\n options?: { maxDepth?: number; exactMatch?: boolean },\n ): {\n module: AFSModule;\n modulePath: string;\n maxDepth: number;\n subpath: string;\n remainedModulePath: string;\n }[] {\n const maxDepth = Math.max(options?.maxDepth ?? DEFAULT_MAX_DEPTH, 1);\n const matched: ReturnType<typeof this.findModulesInNamespace> = [];\n\n for (const entry of this.mounts.values()) {\n // Only consider mounts in the specified namespace\n if (entry.namespace !== namespace) continue;\n\n const modulePath = entry.path;\n const module = entry.module;\n\n const pathSegments = path.split(\"/\").filter(Boolean);\n const modulePathSegments = modulePath.split(\"/\").filter(Boolean);\n\n let newMaxDepth: number;\n let subpath: string;\n let remainedModulePath: string;\n\n // Check if modulePath is under path (modulePath starts with path)\n // Must be exact segment match: /github/ArcBlock/afs should NOT match /github/ArcBlock/afsd\n const moduleUnderPath =\n !options?.exactMatch &&\n modulePath.startsWith(path) &&\n (modulePath === path || path === \"/\" || modulePath[path.length] === \"/\");\n\n // Check if path is under modulePath (path starts with modulePath)\n // Must be exact segment match\n const pathUnderModule =\n path.startsWith(modulePath) &&\n (path === modulePath || modulePath === \"/\" || path[modulePath.length] === \"/\");\n\n if (moduleUnderPath) {\n newMaxDepth = Math.max(0, maxDepth - (modulePathSegments.length - pathSegments.length));\n subpath = \"/\";\n remainedModulePath = joinURL(\n \"/\",\n ...modulePathSegments.slice(pathSegments.length).slice(0, maxDepth),\n );\n } else if (pathUnderModule) {\n newMaxDepth = maxDepth;\n subpath = joinURL(\"/\", ...pathSegments.slice(modulePathSegments.length));\n remainedModulePath = \"/\";\n } else {\n continue;\n }\n\n if (newMaxDepth < 0) continue;\n\n matched.push({\n module,\n modulePath,\n maxDepth: newMaxDepth,\n subpath,\n remainedModulePath,\n });\n }\n\n return matched;\n }\n\n async list(path: string, options: AFSListOptions = {}): Promise<AFSListResult> {\n // Parse path with potential namespace\n const { namespace, path: normalizedPath } = this.parsePathWithNamespace(path);\n\n // Handle root-level /.actions listing\n if (normalizedPath === \"/.actions\" && namespace === null) {\n return this.listRootActions();\n }\n\n return await this._list(normalizedPath, namespace, options);\n }\n\n private async _list(\n path: string,\n namespace: string | null,\n options: AFSListOptions = {},\n ): Promise<AFSListResult> {\n // maxDepth=0: return empty array (no children levels to expand)\n if (options?.maxDepth === 0) {\n return { data: [] };\n }\n\n const results: AFSEntry[] = [];\n\n // Special case: listing root \"/\" in default namespace with mounts under /modules\n // (for backward compatibility with legacy behavior that mounted everything under /modules)\n // Only apply this if there are actual mounts with paths starting with /modules\n const hasModulesMounts =\n namespace === null &&\n [...this.mounts.values()].some(\n (m) => m.namespace === null && m.path.startsWith(`${MODULES_ROOT_DIR}/`),\n );\n\n if (path === \"/\" && hasModulesMounts) {\n const maxDepth = options?.maxDepth ?? DEFAULT_MAX_DEPTH;\n\n // Always include /modules directory first\n // Count modules in this namespace\n let moduleCount = 0;\n for (const entry of this.mounts.values()) {\n if (entry.namespace === namespace) {\n moduleCount++;\n }\n }\n results.push({\n id: \"modules\",\n path: MODULES_ROOT_DIR,\n summary: \"All mounted modules\",\n meta: {\n childrenCount: moduleCount,\n description: \"All mounted modules\",\n },\n });\n\n if (maxDepth === 1) {\n // Only show /modules directory\n return { data: results };\n }\n\n // For maxDepth > 1, also get children of /modules with reduced depth\n const childrenResult = await this._list(MODULES_ROOT_DIR, namespace, {\n ...options,\n maxDepth: maxDepth - 1,\n });\n results.push(...childrenResult.data);\n\n return { data: results };\n }\n\n const matches = this.findModulesInNamespace(path, namespace, options);\n\n // If no modules match, return empty results (consistent with filesystem semantics)\n if (matches.length === 0) {\n return { data: results };\n }\n\n // Track virtual intermediate directories to deduplicate\n const virtualDirs = new Map<string, number>();\n\n for (const matched of matches) {\n if (matched.maxDepth === 0) {\n // Compute the depth-truncated path\n const truncatedPath = joinURL(path, matched.remainedModulePath);\n\n if (truncatedPath === matched.modulePath) {\n // Mount point is within depth budget, show as-is\n const moduleEntry: AFSEntry = {\n id: matched.module.name,\n path: matched.modulePath,\n summary: matched.module.description,\n meta: {\n childrenCount: -1, // Unknown, may have children\n description: matched.module.description,\n },\n };\n results.push(moduleEntry);\n } else {\n // Mount point is deeper than depth allows — record virtual dir\n virtualDirs.set(truncatedPath, (virtualDirs.get(truncatedPath) ?? 0) + 1);\n }\n continue;\n }\n\n if (!matched.module.list) {\n // Fallback: Provider has no list method\n // Use childrenCount from read() to determine behavior\n if (matched.module.read) {\n try {\n const readResult = await matched.module.read(matched.subpath);\n const childrenCount = readResult.data?.meta?.childrenCount;\n\n // If childrenCount is undefined or 0, return empty array (leaf node)\n if (childrenCount === undefined || childrenCount === 0) {\n // Leaf node, no children to list\n continue;\n }\n\n // If childrenCount > 0 or -1, provider must implement list()\n throw new Error(\n `Provider '${matched.module.name}' has childrenCount=${childrenCount} but does not implement list(). ` +\n `Providers with children must implement the list() method.`,\n );\n } catch (error) {\n // Re-throw if it's our own error about missing list\n if (error instanceof Error && error.message.includes(\"does not implement list\")) {\n throw error;\n }\n // read() failed, skip this module\n continue;\n }\n }\n continue;\n }\n\n try {\n const result = await matched.module.list(matched.subpath, {\n ...options,\n maxDepth: matched.maxDepth,\n });\n\n const children = result.data.map((entry) => ({\n ...entry,\n path: joinURL(matched.modulePath, entry.path),\n }));\n\n // Always include all nodes (including the current path itself)\n // This ensures consistent behavior across all listing scenarios\n results.push(...children);\n\n // If provider returned a message (e.g., error or warning), surface it\n if (result.message && children.length === 0) {\n return { data: results, message: result.message };\n }\n } catch (error) {\n throw new Error(`Error listing from module at ${matched.modulePath}: ${error.message}`);\n }\n }\n\n // Emit deduplicated virtual intermediate directory entries\n for (const [dirPath] of virtualDirs) {\n const dirName = dirPath.split(\"/\").filter(Boolean).pop() || \"\";\n results.push({\n id: dirName,\n path: dirPath,\n meta: {\n childrenCount: -1,\n },\n });\n }\n\n return { data: results };\n }\n\n /**\n * Check if a path should skip auto-enrichment.\n * Paths ending with /.meta or /.actions should not be enriched\n * to avoid recursive fetches, but their children (e.g., /.meta/kinds)\n * can still be enriched.\n */\n private shouldSkipEnrich(path: string): boolean {\n return path.endsWith(\"/.meta\") || path.endsWith(\"/.actions\");\n }\n\n /**\n * Fetch actions for a path by listing path/.actions.\n * Returns ActionSummary[] on success, [] on failure.\n */\n private async fetchActions(module: AFSModule, subpath: string): Promise<ActionSummary[]> {\n try {\n const actionsPath = joinURL(subpath, \".actions\");\n const result = await module.list?.(actionsPath);\n if (!result?.data) return [];\n\n return result.data\n .filter((entry) => entry.meta?.kind === \"afs:executable\")\n .map((entry) => ({\n name: entry.id,\n description: entry.meta?.description as string | undefined,\n inputSchema: entry.meta?.inputSchema as ActionSummary[\"inputSchema\"],\n }));\n } catch {\n return [];\n }\n }\n\n /**\n * Fetch meta for a path by reading path/.meta.\n * Returns the meta content on success, null on failure.\n */\n private async fetchMeta(\n module: AFSModule,\n subpath: string,\n ): Promise<Record<string, unknown> | null> {\n try {\n const metaPath = joinURL(subpath, \".meta\");\n const result = await module.read?.(metaPath);\n if (!result?.data?.content) return null;\n\n // content should be an object containing meta fields\n const content = result.data.content;\n if (typeof content === \"object\" && content !== null && !Array.isArray(content)) {\n return content as Record<string, unknown>;\n }\n return null;\n } catch {\n return null;\n }\n }\n\n /**\n * Type for data that can be enriched (has path, optional actions, optional meta)\n */\n private async enrichData<\n T extends { path: string; actions?: ActionSummary[]; meta?: Record<string, unknown> | null },\n >(data: T, module: AFSModule, subpath: string): Promise<T> {\n // Skip enrichment for virtual paths\n if (this.shouldSkipEnrich(subpath)) {\n return data;\n }\n\n const result = { ...data };\n const enrichPromises: Promise<void>[] = [];\n\n // Fetch actions if not present (undefined means fetch, [] means keep as-is)\n if (result.actions === undefined) {\n enrichPromises.push(\n this.fetchActions(module, subpath).then((actions) => {\n result.actions = actions;\n }),\n );\n }\n\n // Fetch meta if kind is not present\n if (result.meta?.kind === undefined) {\n enrichPromises.push(\n this.fetchMeta(module, subpath).then((meta) => {\n if (meta) {\n result.meta = { ...result.meta, ...meta };\n }\n }),\n );\n }\n\n await Promise.all(enrichPromises);\n return result;\n }\n\n async read(path: string, _options?: AFSReadOptions): Promise<AFSReadResult> {\n // Parse path with potential namespace\n const { namespace, path: normalizedPath } = this.parsePathWithNamespace(path);\n\n // Special handling for root system paths\n if (namespace === null) {\n if (normalizedPath.startsWith(\"/.actions/\")) {\n return this.readRootAction(normalizedPath);\n }\n if (normalizedPath === \"/.actions\") {\n return this.readRootActions();\n }\n if (normalizedPath === \"/.meta\") {\n return this.readRootMeta();\n }\n }\n\n // Special handling for /.meta/.capabilities\n if (normalizedPath === \"/.meta/.capabilities\") {\n const capabilities = await this.aggregateCapabilities(namespace);\n return {\n data: {\n id: \".capabilities\",\n path: \"/.meta/.capabilities\",\n content: capabilities,\n meta: {\n kind: \"afs:capabilities\",\n },\n },\n };\n }\n\n const modules = this.findModulesInNamespace(normalizedPath, namespace, { exactMatch: true });\n\n for (const { module, modulePath, subpath } of modules) {\n const res = await module.read?.(subpath);\n\n if (res?.data) {\n // Enrich entry with actions and meta if not present\n const enrichedData = await this.enrichData(res.data, module, subpath);\n return {\n ...res,\n data: {\n ...enrichedData,\n path: joinURL(modulePath, res.data.path),\n },\n };\n }\n }\n\n // Check if path is a virtual intermediate directory (parent of mount paths)\n const virtualDir = this.resolveVirtualDirectory(normalizedPath, namespace);\n if (virtualDir) {\n return virtualDir;\n }\n\n throw new AFSNotFoundError(path);\n }\n\n /**\n * Check if a path is a virtual intermediate directory.\n * Returns a read result if the path is a parent of one or more mount paths.\n */\n private resolveVirtualDirectory(path: string, namespace: string | null): AFSReadResult | null {\n const pathSegments = path.split(\"/\").filter(Boolean);\n const childNames = new Set<string>();\n\n for (const entry of this.mounts.values()) {\n if (entry.namespace !== namespace) continue;\n\n const moduleSegments = entry.path.split(\"/\").filter(Boolean);\n\n // Mount must be deeper than the query path\n if (moduleSegments.length <= pathSegments.length) continue;\n\n // Check segment-by-segment prefix match\n let match = true;\n for (let i = 0; i < pathSegments.length; i++) {\n if (moduleSegments[i] !== pathSegments[i]) {\n match = false;\n break;\n }\n }\n\n if (match) {\n childNames.add(moduleSegments[pathSegments.length]!);\n }\n }\n\n if (childNames.size === 0) return null;\n\n const dirName = pathSegments[pathSegments.length - 1] || \"/\";\n return {\n data: {\n id: dirName,\n path,\n meta: {\n childrenCount: childNames.size,\n },\n },\n };\n }\n\n /**\n * Aggregate capabilities from all mounted providers.\n *\n * For each provider:\n * - Read /.meta/.capabilities\n * - Merge tools with provider prefix and mount path prefix\n * - Merge actions with mount path prefix on discovery.pathTemplate\n * - Silently skip providers that fail or don't implement capabilities\n */\n private async aggregateCapabilities(namespace: string | null): Promise<AggregatedCapabilities> {\n const allTools: ToolDefinition[] = [];\n const allActions: ActionCatalog[] = [];\n const skipped: string[] = [];\n const allOperations: OperationsDeclaration[] = [];\n\n // Get all mounts in the specified namespace\n const mounts = this.getMounts(namespace);\n\n for (const mount of mounts) {\n const { path: mountPath, module: provider } = mount;\n\n try {\n // Try to read provider's capabilities\n const result = await provider.read?.(\"/.meta/.capabilities\");\n const content = result?.data?.content;\n\n if (!content) {\n // Provider doesn't implement capabilities, skip silently\n continue;\n }\n\n const manifest = content as CapabilitiesManifest;\n\n // Merge tools with provider prefix and mount path prefix\n for (const tool of manifest.tools ?? []) {\n allTools.push({\n ...tool,\n name: `${manifest.provider}.${tool.name}`,\n path: joinURL(mountPath, tool.path),\n });\n }\n\n // Merge actions with mount path prefix on pathTemplate\n for (const actionCatalog of manifest.actions ?? []) {\n allActions.push({\n ...actionCatalog,\n discovery: {\n ...actionCatalog.discovery,\n pathTemplate: joinURL(mountPath, actionCatalog.discovery.pathTemplate),\n },\n });\n }\n\n // Collect operations declarations\n if (manifest.operations) {\n allOperations.push(manifest.operations);\n }\n } catch {\n // Record skipped mount path (don't expose error details)\n skipped.push(mountPath);\n }\n }\n\n const result: AggregatedCapabilities = {\n schemaVersion: 1,\n provider: \"afs\",\n description: \"AFS aggregated capabilities\",\n tools: allTools,\n actions: allActions,\n };\n\n // Merge operations: OR across all providers (if any provider supports an op, it's available)\n if (allOperations.length > 0) {\n result.operations = {\n read: allOperations.some((o) => o.read),\n list: allOperations.some((o) => o.list),\n write: allOperations.some((o) => o.write),\n delete: allOperations.some((o) => o.delete),\n search: allOperations.some((o) => o.search),\n exec: allOperations.some((o) => o.exec),\n stat: allOperations.some((o) => o.stat),\n explain: allOperations.some((o) => o.explain),\n };\n }\n\n // Add partial/skipped fields if any providers were skipped\n if (skipped.length > 0) {\n result.partial = true;\n result.skipped = skipped;\n }\n\n return result;\n }\n\n async write(\n path: string,\n content: AFSWriteEntryPayload,\n options?: AFSWriteOptions,\n ): Promise<AFSWriteResult> {\n // Parse path with potential namespace\n const { namespace, path: normalizedPath } = this.parsePathWithNamespace(path);\n\n const module = this.findModulesInNamespace(normalizedPath, namespace, { exactMatch: true })[0];\n if (!module?.module.write)\n throw new Error(\n `No module found for path: ${normalizedPath} in namespace '${namespace ?? \"default\"}'`,\n );\n\n this.checkWritePermission(module.module, \"write\", path);\n\n const res = await module.module.write(module.subpath, content, options);\n\n const result = {\n ...res,\n data: {\n ...res.data,\n path: joinURL(module.modulePath, res.data.path),\n },\n };\n this.notifyChange({\n kind: \"write\",\n path: result.data.path,\n moduleName: module.module.name,\n timestamp: Date.now(),\n });\n return result;\n }\n\n async delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult> {\n // Parse path with potential namespace\n const { namespace, path: normalizedPath } = this.parsePathWithNamespace(path);\n\n const module = this.findModulesInNamespace(normalizedPath, namespace, { exactMatch: true })[0];\n if (!module?.module.delete)\n throw new Error(\n `No module found for path: ${normalizedPath} in namespace '${namespace ?? \"default\"}'`,\n );\n\n this.checkWritePermission(module.module, \"delete\", path);\n\n const result = await module.module.delete(module.subpath, options);\n this.notifyChange({\n kind: \"delete\",\n path: joinURL(module.modulePath, module.subpath),\n moduleName: module.module.name,\n timestamp: Date.now(),\n });\n return result;\n }\n\n async rename(\n oldPath: string,\n newPath: string,\n options?: AFSRenameOptions,\n ): Promise<AFSRenameResult> {\n // Parse paths with potential namespaces\n const { namespace: oldNamespace, path: normalizedOldPath } =\n this.parsePathWithNamespace(oldPath);\n const { namespace: newNamespace, path: normalizedNewPath } =\n this.parsePathWithNamespace(newPath);\n\n // Both paths must be in the same namespace\n if (oldNamespace !== newNamespace) {\n throw new Error(`Cannot rename across different namespaces.`);\n }\n\n const oldModule = this.findModulesInNamespace(normalizedOldPath, oldNamespace, {\n exactMatch: true,\n })[0];\n const newModule = this.findModulesInNamespace(normalizedNewPath, newNamespace, {\n exactMatch: true,\n })[0];\n\n // Both paths must be in the same module\n if (!oldModule || !newModule || oldModule.modulePath !== newModule.modulePath) {\n throw new Error(\n `Cannot rename across different modules. Both paths must be in the same module.`,\n );\n }\n\n if (!oldModule.module.rename) {\n throw new Error(`Module does not support rename operation: ${oldModule.modulePath}`);\n }\n\n this.checkWritePermission(oldModule.module, \"rename\", oldPath);\n\n const result = await oldModule.module.rename(oldModule.subpath, newModule.subpath, options);\n this.notifyChange({\n kind: \"rename\",\n path: joinURL(oldModule.modulePath, oldModule.subpath),\n moduleName: oldModule.module.name,\n namespace: oldNamespace,\n meta: { newPath: joinURL(newModule.modulePath, newModule.subpath) },\n timestamp: Date.now(),\n });\n return result;\n }\n\n async search(\n path: string,\n query: string,\n options: AFSSearchOptions = {},\n ): Promise<AFSSearchResult> {\n // Parse path with potential namespace\n const { namespace, path: normalizedPath } = this.parsePathWithNamespace(path);\n return await this._search(normalizedPath, namespace, query, options);\n }\n\n private async _search(\n path: string,\n namespace: string | null,\n query: string,\n options?: AFSSearchOptions,\n ): Promise<AFSSearchResult> {\n const results: AFSEntry[] = [];\n const messages: string[] = [];\n\n for (const { module, modulePath, subpath } of this.findModulesInNamespace(path, namespace)) {\n if (!module.search) continue;\n\n try {\n const { data, message } = await module.search(subpath, query, options);\n\n results.push(\n ...data.map((entry) => ({\n ...entry,\n path: joinURL(modulePath, entry.path),\n })),\n );\n if (message) messages.push(message);\n } catch (error) {\n throw new Error(`Error searching in module at ${modulePath}: ${error.message}`);\n }\n }\n\n return { data: results, message: messages.join(\"; \") };\n }\n\n async exec(\n path: string,\n args: Record<string, any>,\n options: AFSExecOptions = {},\n ): Promise<AFSExecResult> {\n // Parse path with potential namespace\n const { namespace, path: normalizedPath } = this.parsePathWithNamespace(path);\n\n // Handle root-level actions (/.actions/*)\n if (normalizedPath.startsWith(\"/.actions/\")) {\n return await this.execRootAction(normalizedPath, args);\n }\n\n const module = this.findModulesInNamespace(normalizedPath, namespace)[0];\n if (!module?.module.exec)\n throw new Error(\n `No module found for path: ${normalizedPath} in namespace '${namespace ?? \"default\"}'`,\n );\n\n this.checkWritePermission(module.module, \"exec\", path);\n\n // Validate args against inputSchema if available\n await this.validateExecInput(module.module, module.subpath, args);\n\n // Inject AFS instance into context so providers can perform cross-provider operations\n const enhancedOptions: AFSExecOptions = {\n ...options,\n context: { ...options?.context, afs: this },\n };\n\n return await module.module.exec(module.subpath, args, enhancedOptions);\n }\n\n /**\n * Read a root-level action entry (/.actions/mount, /.actions/unmount).\n * Returns the action entry with metadata including inputSchema.\n */\n private async readRootAction(path: string): Promise<AFSReadResult> {\n const actionName = path.slice(\"/.actions/\".length);\n const { data: actions } = await this.listRootActions();\n const entry = actions.find((a) => a.id === actionName);\n if (!entry) {\n throw new AFSNotFoundError(path, `Root action not found: ${actionName}`);\n }\n\n // Surface inputSchema and description in meta for fetchActionMeta compatibility\n const action = entry.actions?.[0];\n return {\n data: {\n ...entry,\n content: {\n description: action?.description,\n inputSchema: action?.inputSchema,\n },\n meta: {\n ...entry.meta,\n description: action?.description,\n inputSchema: action?.inputSchema,\n },\n },\n };\n }\n\n /**\n * Read root metadata (/.meta).\n * Returns mounted providers list, root actions, and childrenCount.\n */\n private async readRootMeta(): Promise<AFSReadResult> {\n const mounts = this.getMounts(null);\n const { data: actions } = await this.listRootActions();\n\n const mountedProviders = mounts.map((m) => {\n const mod = m.module;\n const operations: string[] = [];\n if (mod.read) operations.push(\"read\");\n if (mod.list) operations.push(\"list\");\n if (mod.stat) operations.push(\"stat\");\n if (mod.write) operations.push(\"write\");\n if (mod.delete) operations.push(\"delete\");\n if (mod.search) operations.push(\"search\");\n if (mod.exec) operations.push(\"exec\");\n if (mod.explain) operations.push(\"explain\");\n if (mod.rename) operations.push(\"rename\");\n return {\n name: mod.name,\n path: m.path,\n description: mod.description,\n operations,\n };\n });\n\n const rootActions = actions.map((a) => ({\n name: a.id,\n description: a.actions?.[0]?.description || a.summary || \"\",\n }));\n\n return {\n data: {\n id: \".meta\",\n path: \"/.meta\",\n content: {\n description: \"AFS root metadata\",\n childrenCount: mounts.length,\n mountedProviders,\n rootActions,\n },\n meta: {\n kind: \"afs:meta\",\n },\n },\n };\n }\n\n /**\n * Read root actions directory (/.actions).\n * Returns content with actions list.\n */\n private async readRootActions(): Promise<AFSReadResult> {\n const { data: actions } = await this.listRootActions();\n\n return {\n data: {\n id: \".actions\",\n path: \"/.actions\",\n content: {\n actions: actions.map((a) => ({\n name: a.id,\n path: a.path,\n description: a.actions?.[0]?.description || a.summary || \"\",\n })),\n },\n meta: {\n kind: \"afs:directory\",\n childrenCount: actions.length,\n },\n },\n };\n }\n\n /**\n * Stat a root action path (/.actions or /.actions/{name}).\n */\n private async statRootAction(path: string): Promise<AFSStatResult> {\n if (path === \"/.actions\") {\n const { data: actions } = await this.listRootActions();\n return {\n data: {\n id: \".actions\",\n path: \"/.actions\",\n meta: {\n kind: \"afs:directory\",\n childrenCount: actions.length,\n },\n },\n };\n }\n\n // /.actions/{name} — delegate to readRootAction and strip content\n const readResult = await this.readRootAction(path);\n if (readResult.data) {\n const { content: _content, ...statData } = readResult.data;\n return { data: statData };\n }\n\n throw new AFSNotFoundError(path);\n }\n\n /**\n * Stat a root meta path (/.meta or /.meta/{subpath}).\n */\n private async statRootMeta(path: string): Promise<AFSStatResult> {\n if (path === \"/.meta\") {\n return {\n data: {\n id: \".meta\",\n path: \"/.meta\",\n meta: {\n kind: \"afs:meta\",\n childrenCount: 1, // .capabilities\n },\n },\n };\n }\n\n if (path === \"/.meta/.capabilities\") {\n return {\n data: {\n id: \".capabilities\",\n path: \"/.meta/.capabilities\",\n meta: {\n kind: \"afs:capabilities\",\n },\n },\n };\n }\n\n throw new AFSNotFoundError(path);\n }\n\n /**\n * List root-level actions (/.actions).\n */\n private async listRootActions(): Promise<AFSListResult> {\n const actions: AFSEntry[] = [];\n\n if (this.loadProvider) {\n actions.push({\n id: \"mount\",\n path: \"/.actions/mount\",\n summary: \"Mount a new provider\",\n meta: {\n kind: \"afs:executable\",\n kinds: [\"afs:executable\", \"afs:node\"],\n },\n actions: [\n {\n name: \"mount\",\n description: \"Mount a provider from URI\",\n inputSchema: {\n type: \"object\",\n properties: {\n uri: { type: \"string\", description: \"Provider URI\" },\n path: { type: \"string\", description: \"Mount path\" },\n accessMode: {\n type: \"string\",\n enum: [\"readonly\", \"readwrite\"],\n description: \"Access mode (default: readonly)\",\n },\n auth: { type: \"string\", description: \"Authentication token\" },\n description: { type: \"string\", description: \"Human-readable description\" },\n scope: {\n type: \"string\",\n enum: [\"cwd\", \"project\", \"user\"],\n description:\n \"Where to persist the mount config. 'cwd' (default) = current directory, 'project' = project root (.git), 'user' = user home\",\n },\n sensitiveArgs: {\n type: \"array\",\n items: { type: \"string\" },\n description:\n \"Field names that should be treated as sensitive credentials (stored in credentials.toml instead of config.toml)\",\n },\n },\n required: [\"uri\", \"path\"],\n },\n },\n ],\n });\n }\n\n actions.push({\n id: \"unmount\",\n path: \"/.actions/unmount\",\n summary: \"Unmount a provider\",\n meta: {\n kind: \"afs:executable\",\n kinds: [\"afs:executable\", \"afs:node\"],\n },\n actions: [\n {\n name: \"unmount\",\n description: \"Unmount a provider at a given path\",\n inputSchema: {\n type: \"object\",\n properties: {\n path: { type: \"string\", description: \"Path to unmount\" },\n scope: {\n type: \"string\",\n enum: [\"cwd\", \"project\", \"user\"],\n description: \"Config scope to remove mount from. If omitted, searches all scopes.\",\n },\n },\n required: [\"path\"],\n },\n },\n ],\n });\n\n return { data: actions };\n }\n\n /**\n * Handle root-level action execution (/.actions/*).\n * Supports:\n * - /.actions/mount: Load and mount a provider via loadProvider\n * - /.actions/unmount: Unmount a provider at a given path\n */\n private async execRootAction(path: string, args: Record<string, any>): Promise<AFSExecResult> {\n const actionName = path.slice(\"/.actions/\".length);\n\n if (actionName === \"mount\") {\n return await this.execRootMountAction(args);\n }\n\n if (actionName === \"unmount\") {\n return await this.execRootUnmountAction(args);\n }\n\n throw new AFSNotFoundError(path, `Root action not found: ${actionName}`);\n }\n\n /**\n * Execute root-level mount action.\n * Validates input and delegates to loadProvider.\n */\n private async execRootMountAction(args: Record<string, any>): Promise<AFSExecResult> {\n // Validate required params\n if (typeof args.uri !== \"string\" || args.uri === \"\") {\n throw new AFSValidationError(\"Input validation failed: uri: must be a non-empty string\");\n }\n if (typeof args.path !== \"string\" || args.path === \"\") {\n throw new AFSValidationError(\"Input validation failed: path: must be a non-empty string\");\n }\n\n if (!this.loadProvider) {\n throw new Error(\"loadProvider not configured\");\n }\n\n // Pass extra args (accessMode, auth, description, etc.) as options\n const { uri, path, sensitiveArgs, ...options } = args;\n // Attach _sensitiveArgs annotation so credential resolver can build ad-hoc schema\n if (Array.isArray(sensitiveArgs) && sensitiveArgs.length > 0) {\n options._sensitiveArgs = sensitiveArgs;\n }\n await this.loadProvider(uri, path, Object.keys(options).length > 0 ? options : undefined);\n\n return {\n success: true,\n data: { uri, path },\n };\n }\n\n /**\n * Execute root-level unmount action.\n * Validates input and delegates to unmount().\n */\n private async execRootUnmountAction(args: Record<string, any>): Promise<AFSExecResult> {\n if (typeof args.path !== \"string\" || args.path === \"\") {\n throw new AFSValidationError(\"Input validation failed: path: must be a non-empty string\");\n }\n\n const success = this.unmount(args.path);\n if (!success) {\n return {\n success: false,\n error: {\n code: \"NOT_FOUND\",\n message: `No provider mounted at ${args.path}`,\n },\n };\n }\n\n // Sync config removal if unloadProvider is configured\n if (this.unloadProvider) {\n try {\n const { path: _path, ...options } = args;\n await this.unloadProvider(args.path, Object.keys(options).length > 0 ? options : undefined);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n console.warn(`[unmount] config persistence failed: ${msg}`);\n }\n }\n\n return {\n success: true,\n data: { path: args.path },\n };\n }\n\n /**\n * Validate exec input args against inputSchema.\n * Throws AFSValidationError if validation fails.\n * Uses zod-from-json-schema for full JSON Schema validation.\n */\n private async validateExecInput(\n module: AFSModule,\n subpath: string,\n args: Record<string, unknown>,\n ): Promise<void> {\n // Try to get inputSchema from the action's metadata\n let inputSchema: Record<string, unknown> | undefined;\n\n if (module.read) {\n try {\n const readResult = await module.read(subpath);\n inputSchema = readResult.data?.meta?.inputSchema as Record<string, unknown> | undefined;\n } catch {\n // If read fails, skip validation\n return;\n }\n }\n\n // If no inputSchema, skip validation\n if (!inputSchema) {\n return;\n }\n\n // Convert JSON Schema to Zod schema and validate\n try {\n const { convertJsonSchemaToZod } = await import(\"zod-from-json-schema\");\n const zodSchema = convertJsonSchemaToZod(inputSchema);\n\n // Check if schema is a valid, usable schema (not z.never() from invalid JSON Schema)\n // z.never() has no properties/type info and always rejects - indicates invalid source schema\n const testResult = zodSchema.safeParse(args);\n if (!testResult.success) {\n // Check if it's a \"never\" type (invalid schema was converted to z.never())\n const hasNeverIssue = testResult.error.issues.some(\n (issue) =>\n issue.message === \"Invalid input: expected never, received object\" ||\n issue.message.startsWith(\"Invalid input: expected never\"),\n );\n if (hasNeverIssue) {\n // Invalid source schema - degrade gracefully, skip validation\n return;\n }\n // Real validation errors - extract field-level messages\n const messages = testResult.error.issues.map((issue) => {\n const path = issue.path.join(\".\");\n return path ? `${path}: ${issue.message}` : issue.message;\n });\n throw new AFSValidationError(`Input validation failed: ${messages.join(\"; \")}`);\n }\n } catch (error) {\n if (error instanceof AFSValidationError) {\n throw error;\n }\n // Non-Zod errors (e.g. schema conversion failure) → skip validation\n }\n }\n\n /**\n * Get stat information for a path\n *\n * Resolution order:\n * 1. Provider's stat() method (if implemented)\n * 2. Fallback to read() - extracts stat data from AFSEntry\n *\n * This allows providers to implement only read() while stat() still works.\n */\n async stat(path: string, options?: AFSStatOptions): Promise<AFSStatResult> {\n // Parse path with potential namespace\n const { namespace, path: normalizedPath } = this.parsePathWithNamespace(path);\n\n // Explicit routes for root system paths (before module lookup)\n if (namespace === null) {\n if (normalizedPath === \"/.actions\" || normalizedPath.startsWith(\"/.actions/\")) {\n return this.statRootAction(normalizedPath);\n }\n if (normalizedPath === \"/.meta\" || normalizedPath.startsWith(\"/.meta/\")) {\n return this.statRootMeta(normalizedPath);\n }\n }\n\n const module = this.findModulesInNamespace(normalizedPath, namespace)[0];\n if (!module) {\n // No match at all — check for virtual intermediate directory\n const virtualDir = this.resolveVirtualDirectory(normalizedPath, namespace);\n if (virtualDir?.data) {\n return { data: virtualDir.data };\n }\n\n // Safety net: fallback to this.read() for paths with read handlers (e.g. /.actions/*)\n try {\n const readResult = await this.read(path);\n if (readResult.data) {\n const { content: _content, ...statData } = readResult.data;\n return { data: statData };\n }\n } catch {\n /* read also failed, throw original error */\n }\n\n throw new AFSNotFoundError(path);\n }\n\n // If the path is a parent of the mount (virtual intermediate directory),\n // return virtual directory data instead of delegating to the provider\n if (module.remainedModulePath !== \"/\") {\n const virtualDir = this.resolveVirtualDirectory(normalizedPath, namespace);\n if (virtualDir?.data) {\n return { data: virtualDir.data };\n }\n }\n\n // Try provider's stat() first\n if (module.module.stat) {\n try {\n const result = await module.module.stat(module.subpath, options);\n\n // Enrich data with actions and meta if present and not already set\n if (result.data) {\n const enrichedData = await this.enrichData(result.data, module.module, module.subpath);\n return {\n ...result,\n data: enrichedData,\n };\n }\n\n // stat returned undefined data - path not found\n throw new AFSNotFoundError(path);\n } catch (error) {\n // Re-throw AFSNotFoundError\n if (error instanceof AFSNotFoundError) {\n throw error;\n }\n // stat() failed, try fallback to read()\n }\n }\n\n // Fallback to read() - extract stat data from AFSEntry (exclude content)\n if (module.module.read) {\n const readResult = await module.module.read(module.subpath, options);\n if (readResult.data) {\n const { content: _content, ...statData } = readResult.data;\n const enrichedData = await this.enrichData(statData, module.module, module.subpath);\n return { data: enrichedData };\n }\n }\n\n throw new AFSNotFoundError(path);\n }\n\n /**\n * Get human-readable explanation for a path\n *\n * Resolution order:\n * 1. Provider's explain() method (if implemented)\n * 2. Fallback to stat() - builds explanation from metadata\n *\n * This allows providers to skip implementing explain() while it still works.\n */\n async explain(path: string, options?: AFSExplainOptions): Promise<AFSExplainResult> {\n // Parse path with potential namespace\n const { namespace, path: normalizedPath } = this.parsePathWithNamespace(path);\n\n // Explicit routes for root system paths (before module lookup)\n if (namespace === null) {\n if (normalizedPath === \"/\") {\n return this.explainRoot();\n }\n if (normalizedPath === \"/.actions\" || normalizedPath.startsWith(\"/.actions/\")) {\n return this.explainRootAction(normalizedPath);\n }\n if (normalizedPath === \"/.meta\" || normalizedPath.startsWith(\"/.meta/\")) {\n return this.explainRootMeta(normalizedPath);\n }\n }\n\n const module = this.findModulesInNamespace(normalizedPath, namespace)[0];\n if (!module) {\n // Check for virtual intermediate directory\n const virtualDir = this.resolveVirtualDirectory(normalizedPath, namespace);\n if (virtualDir?.data) {\n return this.buildVirtualDirExplain(normalizedPath, virtualDir.data);\n }\n\n // Safety net: fallback to this.stat() for paths with stat/read handlers\n try {\n const statResult = await this.stat(path);\n if (statResult.data) {\n return this.buildExplainFromStat(normalizedPath, statResult.data);\n }\n } catch {\n /* stat also failed, throw original error */\n }\n\n throw new AFSNotFoundError(path);\n }\n\n // If the path is a parent of the mount (virtual intermediate directory),\n // return virtual directory explanation\n if (module.remainedModulePath !== \"/\") {\n const virtualDir = this.resolveVirtualDirectory(normalizedPath, namespace);\n if (virtualDir?.data) {\n return this.buildVirtualDirExplain(normalizedPath, virtualDir.data);\n }\n }\n\n // Try provider's explain() first\n if (module.module.explain) {\n try {\n return await module.module.explain(module.subpath, options);\n } catch (error) {\n // Re-throw AFSNotFoundError\n if (error instanceof AFSNotFoundError) {\n throw error;\n }\n // explain() failed, try fallback to stat()\n }\n }\n\n // Fallback to stat() - build explanation from metadata\n const statResult = await this.stat(path, options);\n if (statResult.data) {\n return this.buildExplainFromStat(normalizedPath, statResult.data);\n }\n\n throw new Error(\n `No explain or stat handler for path: ${normalizedPath} in namespace '${namespace ?? \"default\"}'`,\n );\n }\n\n /**\n * Format bytes to human-readable string\n */\n private buildVirtualDirExplain(path: string, data: AFSEntry): AFSExplainResult {\n const childrenCount = data.meta?.childrenCount;\n const lines: string[] = [];\n lines.push(`# ${path}`);\n lines.push(\"\");\n lines.push(\"- **Type**: Virtual directory\");\n if (childrenCount !== undefined) {\n lines.push(`- **Children**: ${childrenCount} items`);\n }\n\n return {\n format: \"markdown\",\n content: lines.join(\"\\n\"),\n };\n }\n\n /**\n * Explain root path ('/').\n * Generates a complete navigation guide with 4 required sections.\n */\n private async explainRoot(): Promise<AFSExplainResult> {\n const lines: string[] = [];\n lines.push(\"# AFS Root\");\n lines.push(\"\");\n\n // Section 1: Mounted Providers\n lines.push(\"## Mounted Providers\");\n lines.push(\"\");\n const mounts = this.getMounts(null);\n if (mounts.length === 0) {\n lines.push(\"No providers currently mounted. Use the `mount` action to add providers.\");\n lines.push(\"\");\n } else {\n for (const m of mounts) {\n if (m.module.description) {\n // Multi-line descriptions: first line as header, rest indented\n const descLines = m.module.description.split(\"\\n\");\n lines.push(`- **${m.module.name}** (\\`${m.path}\\`) — ${descLines[0]}`);\n for (let i = 1; i < descLines.length; i++) {\n lines.push(` ${descLines[i]}`);\n }\n } else {\n lines.push(`- **${m.module.name}** (\\`${m.path}\\`)`);\n }\n }\n lines.push(\"\");\n }\n\n // Section 2: Standard Operations\n lines.push(\"## Standard Operations\");\n lines.push(\"\");\n lines.push(\"- **read** — Read file or node content\");\n lines.push(\"- **list** — List children of a directory or container\");\n lines.push(\"- **stat** — Get metadata without content\");\n lines.push(\"- **explain** — Get human-readable documentation for a path\");\n lines.push(\"- **search** — Search within a mounted provider\");\n lines.push(\"- **write** — Create or update content\");\n lines.push(\"- **delete** — Remove a file or node\");\n lines.push(\"- **exec** — Execute an action at a path\");\n lines.push(\"\");\n\n // Section 3: Root Actions\n lines.push(\"## Root Actions\");\n lines.push(\"\");\n const { data: actions } = await this.listRootActions();\n for (const action of actions) {\n const desc = action.actions?.[0]?.description || action.summary || \"\";\n lines.push(`- **${action.id}** — ${desc}`);\n }\n lines.push(\"\");\n lines.push(\"Use `explain('/.actions/<name>')` for detailed usage.\");\n lines.push(\"\");\n\n // Section 4: Built-in Systems\n lines.push(\"## Built-in Systems\");\n lines.push(\"\");\n lines.push(\n \"- **`.meta`** — Metadata for any node. Access via `read('/.meta')` at root, or append `/.meta` to any path.\",\n );\n lines.push(\n \"- **`.actions`** — Executable actions. Access via `read('/.actions')` to list, `exec('/.actions/<name>', args)` to run.\",\n );\n lines.push(\"\");\n\n return { format: \"markdown\", content: lines.join(\"\\n\") };\n }\n\n /**\n * Explain a root action path (/.actions or /.actions/{name}).\n */\n private async explainRootAction(path: string): Promise<AFSExplainResult> {\n if (path === \"/.actions\") {\n const lines: string[] = [];\n lines.push(\"# Root Actions\");\n lines.push(\"\");\n lines.push(\"Available actions at the AFS root level:\");\n lines.push(\"\");\n const { data: actions } = await this.listRootActions();\n for (const action of actions) {\n const desc = action.actions?.[0]?.description || action.summary || \"\";\n lines.push(`- **${action.id}** — ${desc}`);\n }\n lines.push(\"\");\n lines.push(\"Use `explain('/.actions/<name>')` for detailed parameters and usage.\");\n return { format: \"markdown\", content: lines.join(\"\\n\") };\n }\n\n // /.actions/{name} — generate parameter table from inputSchema\n const actionName = path.slice(\"/.actions/\".length);\n const { data: actions } = await this.listRootActions();\n const entry = actions.find((a) => a.id === actionName);\n if (!entry) {\n throw new AFSNotFoundError(path, `Root action not found: ${actionName}`);\n }\n\n const action = entry.actions?.[0];\n const lines: string[] = [];\n lines.push(`# ${actionName}`);\n lines.push(\"\");\n if (action?.description) {\n lines.push(action.description);\n lines.push(\"\");\n }\n\n // Parameter table from inputSchema\n const schema = action?.inputSchema as Record<string, any> | undefined;\n const properties = schema?.properties as Record<string, any> | undefined;\n const required = (schema?.required as string[]) || [];\n\n if (properties && Object.keys(properties).length > 0) {\n lines.push(\"## Parameters\");\n lines.push(\"\");\n lines.push(\"| Name | Type | Required | Description |\");\n lines.push(\"|------|------|----------|-------------|\");\n for (const [name, prop] of Object.entries(properties)) {\n const type = (prop as any).type || \"any\";\n const isRequired = required.includes(name) ? \"yes\" : \"no\";\n const desc = (prop as any).description || \"\";\n lines.push(`| ${name} | ${type} | ${isRequired} | ${desc} |`);\n }\n lines.push(\"\");\n }\n\n // Usage example\n lines.push(\"## Example\");\n lines.push(\"\");\n const exampleArgs: Record<string, string> = {};\n for (const name of required) {\n exampleArgs[name] = `<${name}>`;\n }\n lines.push(\n `\\`\\`\\`\\nexec('/.actions/${actionName}', ${JSON.stringify(exampleArgs, null, 2)})\\n\\`\\`\\``,\n );\n\n return { format: \"markdown\", content: lines.join(\"\\n\") };\n }\n\n /**\n * Explain a root meta path (/.meta or /.meta/{subpath}).\n */\n private async explainRootMeta(path: string): Promise<AFSExplainResult> {\n if (path === \"/.meta\") {\n const lines: string[] = [];\n lines.push(\"# Root Metadata\");\n lines.push(\"\");\n lines.push(\"The `.meta` system provides metadata about any AFS node.\");\n lines.push(\"\");\n lines.push(\"## Available Sub-paths\");\n lines.push(\"\");\n lines.push(\"- **`.capabilities`** — Aggregated capabilities from all mounted providers\");\n lines.push(\"\");\n lines.push(\n \"Use `read('/.meta')` to get structured root metadata including mounted providers and available actions.\",\n );\n return { format: \"markdown\", content: lines.join(\"\\n\") };\n }\n\n if (path === \"/.meta/.capabilities\") {\n const lines: string[] = [];\n lines.push(\"# Capabilities\");\n lines.push(\"\");\n lines.push(\"Aggregated capabilities manifest from all mounted providers.\");\n lines.push(\n \"Describes the combined operations, tools, and action catalogs available across the system.\",\n );\n lines.push(\"\");\n lines.push(\n \"Use `read('/.meta/.capabilities')` to get the full structured capabilities data.\",\n );\n return { format: \"markdown\", content: lines.join(\"\\n\") };\n }\n\n throw new AFSNotFoundError(path);\n }\n\n /**\n * Build explain markdown from stat data.\n * Used by both the module-found fallback and the no-module safety net.\n */\n private buildExplainFromStat(path: string, data: Omit<AFSEntry, \"content\">): AFSExplainResult {\n const lines: string[] = [];\n lines.push(`# ${path}`);\n lines.push(\"\");\n\n const meta = data.meta || {};\n\n if (meta.size !== undefined) {\n lines.push(`- **Size**: ${this.formatBytes(meta.size as number)}`);\n }\n if (meta.childrenCount !== undefined) {\n lines.push(`- **Children**: ${meta.childrenCount} items`);\n }\n if (data.updatedAt) {\n lines.push(`- **Modified**: ${data.updatedAt.toISOString()}`);\n }\n\n if (meta.description) {\n lines.push(\"\");\n lines.push(\"## Description\");\n lines.push(String(meta.description));\n }\n if (meta.provider) {\n lines.push(`- **Provider**: ${meta.provider}`);\n }\n if (meta.kind) {\n lines.push(`- **Kind**: ${meta.kind}`);\n }\n if (meta.kinds && Array.isArray(meta.kinds)) {\n lines.push(`- **Kinds**: ${meta.kinds.join(\", \")}`);\n }\n\n if (data.actions && data.actions.length > 0) {\n lines.push(\"\");\n lines.push(\"## Actions\");\n for (const action of data.actions) {\n lines.push(`- **${action.name}**${action.description ? `: ${action.description}` : \"\"}`);\n }\n }\n\n return {\n format: \"markdown\",\n content: lines.join(\"\\n\"),\n };\n }\n\n private formatBytes(bytes: number): string {\n if (bytes === 0) return \"0 B\";\n const k = 1024;\n const sizes = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\"];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n return `${Number.parseFloat((bytes / k ** i).toFixed(2))} ${sizes[i]}`;\n }\n\n private physicalPath?: Promise<string>;\n\n async initializePhysicalPath(): Promise<string> {\n this.physicalPath ??= (async () => {\n const path = await import(\"node:path\");\n const os = await import(\"node:os\");\n const fs = await import(\"node:fs/promises\");\n\n const rootDir = path.join(os.tmpdir(), v7());\n await fs.mkdir(rootDir, { recursive: true });\n\n for (const entry of this.mounts.values()) {\n // Create physical path incorporating namespace\n const namespacePart = entry.namespace ?? \"_default\";\n const physicalModulePath = path.join(rootDir, namespacePart, entry.path);\n await fs.mkdir(path.dirname(physicalModulePath), { recursive: true });\n await entry.module.symlinkToPhysical?.(physicalModulePath);\n }\n\n return rootDir;\n })();\n\n return this.physicalPath;\n }\n\n async cleanupPhysicalPath(): Promise<void> {\n if (this.physicalPath) {\n const fs = await import(\"node:fs/promises\");\n\n await fs.rm(await this.physicalPath, { recursive: true, force: true });\n this.physicalPath = undefined;\n }\n }\n}\n"],"mappings":";;;;;;AAqCA,MAAM,oBAAoB;AAE1B,MAAM,mBAAmB;;;;AAKzB,MAAM,wBAAwB;;;;;AAM9B,eAAe,YAAe,SAAqB,IAAwB;CACzE,IAAI;CAEJ,MAAM,iBAAiB,IAAI,SAAgB,GAAG,WAAW;AACvD,cAAY,iBAAiB,uBAAO,IAAI,MAAM,iBAAiB,GAAG,IAAI,CAAC,EAAE,GAAG;GAC5E;AAEF,KAAI;AACF,SAAO,MAAM,QAAQ,KAAK,CAAC,SAAS,eAAe,CAAC;WAC5C;AACR,eAAa,UAAW;;;;;;;AAQ5B,SAAS,WAAW,UAA6B;AAC/C,QAAO,SAAS,WAAW;;;;;AAM7B,SAAS,qBAAqB,KAAc,SAAyB;AACnE,KAAI,eAAe,OAAO;AACxB,MAAI,IAAI,QAAQ,SAAS,UAAU,CACjC,QAAO,iBAAiB,QAAQ;AAElC,SAAO,IAAI;;AAEb,QAAO,OAAO,IAAI;;;;;AAMpB,MAAM,4BAA4B;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;AAMD,SAAS,sBAAsB,WAAyB;AACtD,KAAI,UAAU,MAAM,KAAK,GACvB,OAAM,IAAI,MAAM,+CAA+C;AAGjE,MAAK,MAAM,QAAQ,0BACjB,KAAI,UAAU,SAAS,KAAK,CAC1B,OAAM,IAAI,MAAM,4CAA4C,KAAK,GAAG;;AAyC1E,IAAa,MAAb,MAAoC;CAClC,OAAe;;;;;;;;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.mjs";
|
|
2
|
+
import { AFSWorldMappingCapable, ExternalRef, MappingStatus, MutateAction, MutateResult, ProjectionContext, isWorldMappingCapable } from "./world-mapping.mjs";
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { JSONSchema7 } from "../node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/capabilities/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Tool definition for global callable tools.
|
|
6
|
+
* Tools are not bound to specific nodes and can be invoked directly.
|
|
7
|
+
*/
|
|
8
|
+
interface ToolDefinition {
|
|
9
|
+
/** Tool name (unique within provider, without provider prefix) */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Tool description */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** Path to executable node (must point to afs:executable) */
|
|
14
|
+
path: string;
|
|
15
|
+
/** Input parameters schema */
|
|
16
|
+
inputSchema?: JSONSchema7;
|
|
17
|
+
/** Output result schema (optional) */
|
|
18
|
+
outputSchema?: JSONSchema7;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Action definition within a catalog.
|
|
22
|
+
* Actions are node-level operations that require targeting a specific node.
|
|
23
|
+
*/
|
|
24
|
+
interface ActionDefinition {
|
|
25
|
+
/** Action name */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Action description */
|
|
28
|
+
description?: string;
|
|
29
|
+
/** Input parameters schema (optional) */
|
|
30
|
+
inputSchema?: JSONSchema7;
|
|
31
|
+
/** Output result schema (optional) */
|
|
32
|
+
outputSchema?: JSONSchema7;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Action catalog describing available actions for a kind of node.
|
|
36
|
+
*/
|
|
37
|
+
interface ActionCatalog {
|
|
38
|
+
/** Kind name (optional, e.g., "sqlite:row", "ec2:instance") */
|
|
39
|
+
kind?: string;
|
|
40
|
+
/** Description (when no kind, describes the applicable scenario) */
|
|
41
|
+
description?: string;
|
|
42
|
+
/** List of possible actions (catalog/documentation) */
|
|
43
|
+
catalog: ActionDefinition[];
|
|
44
|
+
/** Discovery information for finding actual available actions */
|
|
45
|
+
discovery: {
|
|
46
|
+
/**
|
|
47
|
+
* Path template for node-level .actions
|
|
48
|
+
* - Must start with / (relative to provider root)
|
|
49
|
+
* - Uses :param syntax for path parameters (e.g., /:table/:pk/.actions)
|
|
50
|
+
* - Core aggregation adds mount path prefix
|
|
51
|
+
*/
|
|
52
|
+
pathTemplate: string; /** Optional note (e.g., "List to confirm availability") */
|
|
53
|
+
note?: string;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Declares which AFS operations a provider supports.
|
|
58
|
+
*/
|
|
59
|
+
interface OperationsDeclaration {
|
|
60
|
+
read: boolean;
|
|
61
|
+
list: boolean;
|
|
62
|
+
write: boolean;
|
|
63
|
+
delete: boolean;
|
|
64
|
+
search: boolean;
|
|
65
|
+
exec: boolean;
|
|
66
|
+
stat: boolean;
|
|
67
|
+
explain: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Capabilities manifest returned by a provider.
|
|
71
|
+
*/
|
|
72
|
+
interface CapabilitiesManifest {
|
|
73
|
+
/** Schema version for evolution compatibility */
|
|
74
|
+
schemaVersion: 1;
|
|
75
|
+
/** Provider name */
|
|
76
|
+
provider: string;
|
|
77
|
+
/** Provider version */
|
|
78
|
+
version?: string;
|
|
79
|
+
/** Provider description */
|
|
80
|
+
description?: string;
|
|
81
|
+
/** Global tools list */
|
|
82
|
+
tools: ToolDefinition[];
|
|
83
|
+
/** Action catalogs list */
|
|
84
|
+
actions: ActionCatalog[];
|
|
85
|
+
/** Declares which AFS operations this provider supports (optional during transition) */
|
|
86
|
+
operations?: OperationsDeclaration;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Aggregated capabilities from all mounted providers.
|
|
90
|
+
* Extends CapabilitiesManifest with aggregation metadata.
|
|
91
|
+
*/
|
|
92
|
+
interface AggregatedCapabilities extends CapabilitiesManifest {
|
|
93
|
+
/** True if some providers were skipped (partial result) */
|
|
94
|
+
partial?: boolean;
|
|
95
|
+
/** List of skipped mount paths (for debugging) */
|
|
96
|
+
skipped?: string[];
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { ActionCatalog, ActionDefinition, AggregatedCapabilities, CapabilitiesManifest, OperationsDeclaration, ToolDefinition };
|
|
100
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/capabilities/types.ts"],"mappings":";;;;;;;UAaiB,cAAA;EAUf;EARA,IAAA;EAQ0B;EAN1B,WAAA;EAae;EAXf,IAAA;;EAEA,WAAA,GAAc,WAAA;EAWd;EATA,YAAA,GAAe,WAAA;AAAA;;;;;UAOA,gBAAA;EAcA;EAZf,IAAA;;EAEA,WAAA;EAYA;EAVA,WAAA,GAAc,WAAA;EAcd;EAZA,YAAA,GAAe,WAAA;AAAA;;;;UAMA,aAAA;EAwBA;EAtBf,IAAA;;EAEA,WAAA;EAqBA;EAnBA,OAAA,EAAS,gBAAA;EAqBT;EAnBA,SAAA;IAqBA;;;;;;IAdE,YAAA,UAuBiC;IArBjC,IAAA;EAAA;AAAA;;;;UAOa,qBAAA;EACf,IAAA;EACA,IAAA;EACA,KAAA;EACA,MAAA;EACA,MAAA;EACA,IAAA;EACA,IAAA;EACA,OAAA;AAAA;;;AA2BF;UArBiB,oBAAA;;EAEf,aAAA;EAmB8C;EAjB9C,QAAA;EAqBA;EAnBA,OAAA;EAmBO;EAjBP,WAAA;;EAEA,KAAA,EAAO,cAAA;;EAEP,OAAA,EAAS,aAAA;;EAET,UAAA,GAAa,qBAAA;AAAA;;;;;UAOE,sBAAA,SAA+B,oBAAA;;EAE9C,OAAA;;EAEA,OAAA;AAAA"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { JSONSchema7 } from "../node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/capabilities/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Tool definition for global callable tools.
|
|
6
|
+
* Tools are not bound to specific nodes and can be invoked directly.
|
|
7
|
+
*/
|
|
8
|
+
interface ToolDefinition {
|
|
9
|
+
/** Tool name (unique within provider, without provider prefix) */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Tool description */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** Path to executable node (must point to afs:executable) */
|
|
14
|
+
path: string;
|
|
15
|
+
/** Input parameters schema */
|
|
16
|
+
inputSchema?: JSONSchema7;
|
|
17
|
+
/** Output result schema (optional) */
|
|
18
|
+
outputSchema?: JSONSchema7;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Action definition within a catalog.
|
|
22
|
+
* Actions are node-level operations that require targeting a specific node.
|
|
23
|
+
*/
|
|
24
|
+
interface ActionDefinition {
|
|
25
|
+
/** Action name */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Action description */
|
|
28
|
+
description?: string;
|
|
29
|
+
/** Input parameters schema (optional) */
|
|
30
|
+
inputSchema?: JSONSchema7;
|
|
31
|
+
/** Output result schema (optional) */
|
|
32
|
+
outputSchema?: JSONSchema7;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Action catalog describing available actions for a kind of node.
|
|
36
|
+
*/
|
|
37
|
+
interface ActionCatalog {
|
|
38
|
+
/** Kind name (optional, e.g., "sqlite:row", "ec2:instance") */
|
|
39
|
+
kind?: string;
|
|
40
|
+
/** Description (when no kind, describes the applicable scenario) */
|
|
41
|
+
description?: string;
|
|
42
|
+
/** List of possible actions (catalog/documentation) */
|
|
43
|
+
catalog: ActionDefinition[];
|
|
44
|
+
/** Discovery information for finding actual available actions */
|
|
45
|
+
discovery: {
|
|
46
|
+
/**
|
|
47
|
+
* Path template for node-level .actions
|
|
48
|
+
* - Must start with / (relative to provider root)
|
|
49
|
+
* - Uses :param syntax for path parameters (e.g., /:table/:pk/.actions)
|
|
50
|
+
* - Core aggregation adds mount path prefix
|
|
51
|
+
*/
|
|
52
|
+
pathTemplate: string; /** Optional note (e.g., "List to confirm availability") */
|
|
53
|
+
note?: string;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Declares which AFS operations a provider supports.
|
|
58
|
+
*/
|
|
59
|
+
interface OperationsDeclaration {
|
|
60
|
+
read: boolean;
|
|
61
|
+
list: boolean;
|
|
62
|
+
write: boolean;
|
|
63
|
+
delete: boolean;
|
|
64
|
+
search: boolean;
|
|
65
|
+
exec: boolean;
|
|
66
|
+
stat: boolean;
|
|
67
|
+
explain: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Capabilities manifest returned by a provider.
|
|
71
|
+
*/
|
|
72
|
+
interface CapabilitiesManifest {
|
|
73
|
+
/** Schema version for evolution compatibility */
|
|
74
|
+
schemaVersion: 1;
|
|
75
|
+
/** Provider name */
|
|
76
|
+
provider: string;
|
|
77
|
+
/** Provider version */
|
|
78
|
+
version?: string;
|
|
79
|
+
/** Provider description */
|
|
80
|
+
description?: string;
|
|
81
|
+
/** Global tools list */
|
|
82
|
+
tools: ToolDefinition[];
|
|
83
|
+
/** Action catalogs list */
|
|
84
|
+
actions: ActionCatalog[];
|
|
85
|
+
/** Declares which AFS operations this provider supports (optional during transition) */
|
|
86
|
+
operations?: OperationsDeclaration;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Aggregated capabilities from all mounted providers.
|
|
90
|
+
* Extends CapabilitiesManifest with aggregation metadata.
|
|
91
|
+
*/
|
|
92
|
+
interface AggregatedCapabilities extends CapabilitiesManifest {
|
|
93
|
+
/** True if some providers were skipped (partial result) */
|
|
94
|
+
partial?: boolean;
|
|
95
|
+
/** List of skipped mount paths (for debugging) */
|
|
96
|
+
skipped?: string[];
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { ActionCatalog, ActionDefinition, AggregatedCapabilities, CapabilitiesManifest, OperationsDeclaration, ToolDefinition };
|
|
100
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/capabilities/types.ts"],"mappings":";;;;;;;UAaiB,cAAA;EAUf;EARA,IAAA;EAQ0B;EAN1B,WAAA;EAae;EAXf,IAAA;;EAEA,WAAA,GAAc,WAAA;EAWd;EATA,YAAA,GAAe,WAAA;AAAA;;;;;UAOA,gBAAA;EAcA;EAZf,IAAA;;EAEA,WAAA;EAYA;EAVA,WAAA,GAAc,WAAA;EAcd;EAZA,YAAA,GAAe,WAAA;AAAA;;;;UAMA,aAAA;EAwBA;EAtBf,IAAA;;EAEA,WAAA;EAqBA;EAnBA,OAAA,EAAS,gBAAA;EAqBT;EAnBA,SAAA;IAqBA;;;;;;IAdE,YAAA,UAuBiC;IArBjC,IAAA;EAAA;AAAA;;;;UAOa,qBAAA;EACf,IAAA;EACA,IAAA;EACA,KAAA;EACA,MAAA;EACA,MAAA;EACA,IAAA;EACA,IAAA;EACA,OAAA;AAAA;;;AA2BF;UArBiB,oBAAA;;EAEf,aAAA;EAmB8C;EAjB9C,QAAA;EAqBA;EAnBA,OAAA;EAmBO;EAjBP,WAAA;;EAEA,KAAA,EAAO,cAAA;;EAEP,OAAA,EAAS,aAAA;;EAET,UAAA,GAAa,qBAAA;AAAA;;;;;UAOE,sBAAA,SAA+B,oBAAA;;EAE9C,OAAA;;EAEA,OAAA;AAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/capabilities/world-mapping.ts
|
|
3
|
+
/**
|
|
4
|
+
* Type guard to check if a module implements World Mapping capability
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* if (isWorldMappingCapable(provider)) {
|
|
9
|
+
* await provider.loadMapping("/config/mapping/github.yaml");
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
function isWorldMappingCapable(module) {
|
|
14
|
+
if (!module) return false;
|
|
15
|
+
const m = module;
|
|
16
|
+
return typeof m.loadMapping === "function" && typeof m.reloadMapping === "function" && typeof m.getMappingStatus === "function" && typeof m.resolve === "function" && typeof m.project === "function" && typeof m.mutate === "function";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.isWorldMappingCapable = isWorldMappingCapable;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { AFSEntry, AFSModule } from "../type.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/capabilities/world-mapping.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Status information for loaded mapping configuration
|
|
6
|
+
*/
|
|
7
|
+
interface MappingStatus {
|
|
8
|
+
/** Whether mapping is loaded */
|
|
9
|
+
loaded: boolean;
|
|
10
|
+
/** Time when mapping was last loaded */
|
|
11
|
+
loadedAt?: Date;
|
|
12
|
+
/** Path to the mapping configuration */
|
|
13
|
+
mappingPath?: string;
|
|
14
|
+
/** Whether mapping is successfully compiled */
|
|
15
|
+
compiled: boolean;
|
|
16
|
+
/** Error message if loading/compilation failed */
|
|
17
|
+
error?: string;
|
|
18
|
+
/** Statistics about the loaded mapping */
|
|
19
|
+
stats?: {
|
|
20
|
+
/** Number of route templates */routes: number; /** Number of supported operations */
|
|
21
|
+
operations: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Reference to an external system resource
|
|
26
|
+
*/
|
|
27
|
+
interface ExternalRef {
|
|
28
|
+
/** Type of external system */
|
|
29
|
+
type: "http" | "graphql" | "mcp-tool" | "custom";
|
|
30
|
+
/** HTTP: URL, GraphQL: query, MCP: tool name */
|
|
31
|
+
target: string;
|
|
32
|
+
/** HTTP method or operation type */
|
|
33
|
+
method?: string;
|
|
34
|
+
/** Bound parameters */
|
|
35
|
+
params?: Record<string, unknown>;
|
|
36
|
+
/** Headers or metadata */
|
|
37
|
+
headers?: Record<string, string>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Context for projecting external data to AFS entries
|
|
41
|
+
*/
|
|
42
|
+
interface ProjectionContext {
|
|
43
|
+
/** Original AFS path */
|
|
44
|
+
path: string;
|
|
45
|
+
/** Matched path template */
|
|
46
|
+
template: string;
|
|
47
|
+
/** Extracted path parameters */
|
|
48
|
+
pathParams: Record<string, string>;
|
|
49
|
+
/** Current mapping rule (opaque to core, interpreted by provider) */
|
|
50
|
+
rule: unknown;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Types of mutation actions
|
|
54
|
+
*/
|
|
55
|
+
type MutateAction = "create" | "update" | "delete" | "exec";
|
|
56
|
+
/**
|
|
57
|
+
* Result of a mutation operation
|
|
58
|
+
*/
|
|
59
|
+
interface MutateResult {
|
|
60
|
+
/** Whether the operation succeeded */
|
|
61
|
+
success: boolean;
|
|
62
|
+
/** Result data from the operation */
|
|
63
|
+
data?: unknown;
|
|
64
|
+
/** Error message if operation failed */
|
|
65
|
+
error?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* World Mapping Capability Interface
|
|
69
|
+
*
|
|
70
|
+
* Providers implement this interface to support declarative path-to-API mapping.
|
|
71
|
+
* The mapping DSL defines how AFS paths map to external API calls.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* class AFSGitHub implements AFSModule, AFSWorldMappingCapable {
|
|
76
|
+
* async loadMapping(mappingPath: string): Promise<void> {
|
|
77
|
+
* // Load and compile mapping from AFS
|
|
78
|
+
* }
|
|
79
|
+
*
|
|
80
|
+
* resolve(path: string): ExternalRef | null {
|
|
81
|
+
* // Match path against compiled routes
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* project(data: unknown, ctx: ProjectionContext): AFSEntry[] {
|
|
85
|
+
* // Transform API response to AFS entries
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
interface AFSWorldMappingCapable {
|
|
91
|
+
/**
|
|
92
|
+
* Load mapping configuration from AFS path
|
|
93
|
+
* @param mappingPath AFS path to mapping configuration file or directory
|
|
94
|
+
*/
|
|
95
|
+
loadMapping(mappingPath: string): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Reload mapping configuration (hot-reload)
|
|
98
|
+
* Should rollback to previous valid configuration on failure
|
|
99
|
+
*/
|
|
100
|
+
reloadMapping(): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Get current mapping status
|
|
103
|
+
*/
|
|
104
|
+
getMappingStatus(): MappingStatus;
|
|
105
|
+
/**
|
|
106
|
+
* Resolve AFS path to external reference
|
|
107
|
+
* @param path AFS internal path
|
|
108
|
+
* @returns External system reference, or null if path doesn't match any route
|
|
109
|
+
*/
|
|
110
|
+
resolve(path: string): ExternalRef | null;
|
|
111
|
+
/**
|
|
112
|
+
* Project external data to AFS entries
|
|
113
|
+
* @param externalData Data returned from external API
|
|
114
|
+
* @param context Resolution context (path, template, params, rule)
|
|
115
|
+
* @returns Array of AFS entries
|
|
116
|
+
*/
|
|
117
|
+
project(externalData: unknown, context: ProjectionContext): AFSEntry[];
|
|
118
|
+
/**
|
|
119
|
+
* Execute mutation operation
|
|
120
|
+
* @param path AFS path
|
|
121
|
+
* @param action Mutation type
|
|
122
|
+
* @param payload Operation parameters
|
|
123
|
+
*/
|
|
124
|
+
mutate(path: string, action: MutateAction, payload: unknown): Promise<MutateResult>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Type guard to check if a module implements World Mapping capability
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* if (isWorldMappingCapable(provider)) {
|
|
132
|
+
* await provider.loadMapping("/config/mapping/github.yaml");
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare function isWorldMappingCapable(module: AFSModule | null | undefined): module is AFSModule & AFSWorldMappingCapable;
|
|
137
|
+
//#endregion
|
|
138
|
+
export { AFSWorldMappingCapable, ExternalRef, MappingStatus, MutateAction, MutateResult, ProjectionContext, isWorldMappingCapable };
|
|
139
|
+
//# sourceMappingURL=world-mapping.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world-mapping.d.cts","names":[],"sources":["../../src/capabilities/world-mapping.ts"],"mappings":";;;;;;UAkBiB,aAAA;EAgBH;EAdZ,MAAA;EAqB0B;EAnB1B,QAAA,GAAW,IAAA;EA6BK;EA3BhB,WAAA;EAqBA;EAnBA,QAAA;EAuBA;EArBA,KAAA;EAuBA;EArBA,KAAA;IAqBgB,gCAnBd,MAAA,UAyBa;IAvBb,UAAA;EAAA;AAAA;;;;UAOa,WAAA;EAwBf;EAtBA,IAAA;EAsBI;EApBJ,MAAA;EA0BsB;EAxBtB,MAAA;EAwBsB;EAtBtB,MAAA,GAAS,MAAA;EA2BM;EAzBf,OAAA,GAAU,MAAA;AAAA;;;;UAMK,iBAAA;EAyBV;EAvBL,IAAA;EAiDe;EA/Cf,QAAA;;EAEA,UAAA,EAAY,MAAA;EAwDK;EAtDjB,IAAA;AAAA;;;;KAMU,YAAA;;;;UAKK,YAAA;EAqCH;EAnCZ,OAAA;EAyCA;EAvCA,IAAA;EA4CA;EA1CA,KAAA;AAAA;;;;;;;;;;;;;;;;;AA8EF;;;;;;;UApDiB,sBAAA;EAqDP;;;;EAhDR,WAAA,CAAY,WAAA,WAAsB,OAAA;EAiDW;;;;EA3C7C,aAAA,IAAiB,OAAA;;;;EAKjB,gBAAA,IAAoB,aAAA;;;;;;EAOpB,OAAA,CAAQ,IAAA,WAAe,WAAA;;;;;;;EAQvB,OAAA,CAAQ,YAAA,WAAuB,OAAA,EAAS,iBAAA,GAAoB,QAAA;;;;;;;EAQ5D,MAAA,CAAO,IAAA,UAAc,MAAA,EAAQ,YAAA,EAAc,OAAA,YAAmB,OAAA,CAAQ,YAAA;AAAA;;;;;;;;;;;iBAaxD,qBAAA,CACd,MAAA,EAAQ,SAAA,sBACP,MAAA,IAAU,SAAA,GAAY,sBAAA"}
|