@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
@@ -0,0 +1,420 @@
1
+ import { JSONSchema7 } from "./node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.mjs";
2
+ import { AFSExplainResult, KindSchema, MetaPathInfo, NodeConstraint, NodesConstraints, ValidationError, ValidationResult } from "./meta/type.mjs";
3
+ import { ZodType, z } from "zod";
4
+
5
+ //#region src/type.d.ts
6
+ /**
7
+ * Abstract auth context interface for collecting credentials.
8
+ * Implementations:
9
+ * - CLI: terminal prompt / masked input / open command
10
+ * - MCP: elicitation form mode / URL mode
11
+ */
12
+ interface AuthContext {
13
+ /** Step 2 resolved fields (env/store/config), so auth() can skip already-resolved fields */
14
+ readonly resolved: Record<string, unknown>;
15
+ /**
16
+ * Collect fields from the user.
17
+ * Implementation auto-selects secure channel based on `sensitive` markers in schema:
18
+ * - All non-sensitive → MCP form mode / CLI prompt
19
+ * - Contains sensitive → MCP URL mode (local HTTP form) / CLI masked input
20
+ *
21
+ * @param schema - JSON Schema describing fields to collect (from z.toJSONSchema() or manifest)
22
+ * @returns collected values, or null if user declined/cancelled
23
+ */
24
+ collect(schema: JSONSchema7): Promise<Record<string, unknown> | null>;
25
+ /**
26
+ * Create a localhost callback server for OAuth redirect_uri flows.
27
+ * Provider uses callbackURL to construct auth URL, then waitForCallback() for the result.
28
+ */
29
+ createCallbackServer(): Promise<CallbackServer>;
30
+ /**
31
+ * Request the client to open a URL (MCP: URL mode elicitation, CLI: open command).
32
+ * Only opens — does not wait for data.
33
+ */
34
+ requestOpenURL(url: string, message: string): Promise<"accepted" | "declined" | "cancelled">;
35
+ }
36
+ /**
37
+ * Localhost callback server for OAuth flows.
38
+ * Created by AuthContext.createCallbackServer().
39
+ */
40
+ interface CallbackServer {
41
+ /** Callback address, e.g. http://127.0.0.1:{port}/callback */
42
+ callbackURL: string;
43
+ /** Wait for a callback request. Returns query params, or null on timeout/cancel. */
44
+ waitForCallback(options?: {
45
+ timeout?: number;
46
+ }): Promise<Record<string, string> | null>;
47
+ /** Close the callback server. Idempotent. */
48
+ close(): void;
49
+ }
50
+ /** AFS change record — pure data, zero external dependencies */
51
+ interface AFSChangeRecord {
52
+ kind: "write" | "delete" | "mount" | "unmount" | "rename";
53
+ path: string;
54
+ /** Module name (for mount/unmount events) */
55
+ moduleName?: string;
56
+ /** Namespace (for mount/unmount events) */
57
+ namespace?: string | null;
58
+ timestamp: number;
59
+ /** Optional metadata — AFS passes through without interpretation */
60
+ meta?: Record<string, unknown>;
61
+ }
62
+ /** Change listener — injected by AOS, called by AFS */
63
+ type AFSChangeListener = (event: AFSChangeRecord) => void;
64
+ /**
65
+ * Access mode for AFS modules and root.
66
+ * - "readonly": Only read operations are allowed (list, read, search)
67
+ * - "readwrite": All operations are allowed
68
+ */
69
+ type AFSAccessMode = "readonly" | "readwrite";
70
+ /**
71
+ * Zod schema for access mode validation.
72
+ * Can be reused across modules that support access mode configuration.
73
+ */
74
+ declare const accessModeSchema: z.ZodOptional<z.ZodEnum<{
75
+ readonly: "readonly";
76
+ readwrite: "readwrite";
77
+ }>>;
78
+ interface AFSOperationOptions {
79
+ context?: any;
80
+ }
81
+ interface AFSListOptions extends AFSOperationOptions {
82
+ filter?: {
83
+ agentId?: string;
84
+ userId?: string;
85
+ sessionId?: string;
86
+ before?: string;
87
+ after?: string;
88
+ };
89
+ maxDepth?: number;
90
+ /**
91
+ * Number of entries to skip (pagination offset)
92
+ * @default 0
93
+ */
94
+ offset?: number;
95
+ /**
96
+ * Maximum number of entries to return
97
+ * @default 1000
98
+ */
99
+ limit?: number;
100
+ orderBy?: [string, "asc" | "desc"][];
101
+ maxChildren?: number;
102
+ onOverflow?: "truncate";
103
+ /**
104
+ * Whether to disable .gitignore files when listing files.
105
+ * @default false
106
+ */
107
+ disableGitignore?: boolean;
108
+ /**
109
+ * Glob pattern to filter entries by path.
110
+ * Examples: "*.ts", "**\/*.js", "src/**\/*.{ts,tsx}"
111
+ */
112
+ pattern?: string;
113
+ }
114
+ interface AFSListResult {
115
+ data: AFSEntry[];
116
+ message?: string;
117
+ /**
118
+ * Total count of entries (optional)
119
+ * - If present: indicates complete dataset size (data may be a subset)
120
+ * - If absent (undefined): data IS the complete result, total === data.length
121
+ */
122
+ total?: number;
123
+ }
124
+ interface AFSSearchOptions extends AFSOperationOptions {
125
+ limit?: number;
126
+ caseSensitive?: boolean;
127
+ }
128
+ interface AFSSearchResult {
129
+ data: AFSEntry[];
130
+ message?: string;
131
+ }
132
+ interface AFSReadOptions extends AFSOperationOptions {
133
+ filter?: AFSListOptions["filter"];
134
+ }
135
+ interface AFSReadResult {
136
+ data?: AFSEntry;
137
+ message?: string;
138
+ }
139
+ interface AFSDeleteOptions extends AFSOperationOptions {
140
+ recursive?: boolean;
141
+ }
142
+ interface AFSDeleteResult {
143
+ message?: string;
144
+ }
145
+ interface AFSRenameOptions extends AFSOperationOptions {
146
+ overwrite?: boolean;
147
+ }
148
+ interface AFSRenameResult {
149
+ message?: string;
150
+ }
151
+ interface AFSWriteOptions extends AFSOperationOptions {
152
+ append?: boolean;
153
+ }
154
+ interface AFSWriteResult {
155
+ data: AFSEntry;
156
+ message?: string;
157
+ }
158
+ interface AFSWriteEntryPayload extends Omit<AFSEntry, "id" | "path"> {}
159
+ interface AFSExecOptions extends AFSOperationOptions {}
160
+ interface AFSExecResult extends AFSActionResult {}
161
+ /**
162
+ * Summary information for an action available on a node.
163
+ * Used in AFSEntry.actions to describe available actions.
164
+ */
165
+ interface ActionSummary {
166
+ /** The action name (e.g., "refresh", "export", "delete") */
167
+ name: string;
168
+ /** Human-readable description of what the action does */
169
+ description?: string;
170
+ /** JSON Schema for input parameters */
171
+ inputSchema?: JSONSchema7;
172
+ }
173
+ /**
174
+ * Result from executing an action via the Action System.
175
+ * Actions return structured results with success/failure status.
176
+ */
177
+ interface AFSActionResult {
178
+ /** Whether the action completed successfully */
179
+ success: boolean;
180
+ /** Data returned by the action on success */
181
+ data?: Record<string, unknown>;
182
+ /** Error information when success is false */
183
+ error?: {
184
+ /** Error code (e.g., "VALIDATION_ERROR", "NOT_FOUND") */code: string; /** Human-readable error message */
185
+ message: string; /** Additional error details */
186
+ details?: Record<string, unknown>;
187
+ };
188
+ }
189
+ interface AFSStatOptions extends AFSOperationOptions {}
190
+ /**
191
+ * Result from stat operation.
192
+ * The data field follows AFSEntry structure but without content.
193
+ */
194
+ interface AFSStatResult {
195
+ data?: Omit<AFSEntry, "content">;
196
+ message?: string;
197
+ }
198
+ interface AFSExplainOptions extends AFSOperationOptions {
199
+ format?: "markdown" | "text";
200
+ }
201
+ interface AFSModule {
202
+ readonly name: string;
203
+ readonly description?: string;
204
+ /**
205
+ * The complete source URI for this provider instance (including query params).
206
+ * Set by ProviderRegistry factories after creating the provider.
207
+ * Used by loadProvider injection to persist mount configuration.
208
+ */
209
+ readonly uri?: string;
210
+ /**
211
+ * Access mode for this module.
212
+ * - "readonly": Only read operations are allowed
213
+ * - "readwrite": All operations are allowed
214
+ * Default behavior is implementation-specific.
215
+ */
216
+ readonly accessMode?: AFSAccessMode;
217
+ /**
218
+ * Enable automatic agent skill scanning for this module.
219
+ * When set to true, the system will scan this module for agent skills.
220
+ * @default false
221
+ */
222
+ readonly agentSkills?: boolean;
223
+ /**
224
+ * Timeout in milliseconds for provider operations.
225
+ * Currently used for mount check.
226
+ * If not specified, uses the default value (10s).
227
+ * Remote providers (MCP, HTTP) may need longer timeouts.
228
+ */
229
+ readonly timeout?: number;
230
+ onMount?(root: AFSRoot, mountPath?: string): void;
231
+ symlinkToPhysical?(path: string): Promise<void>;
232
+ list?(path: string, options?: AFSListOptions): Promise<AFSListResult>;
233
+ read?(path: string, options?: AFSReadOptions): Promise<AFSReadResult>;
234
+ write?(path: string, content: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<AFSWriteResult>;
235
+ delete?(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
236
+ rename?(oldPath: string, newPath: string, options?: AFSRenameOptions): Promise<AFSRenameResult>;
237
+ search?(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;
238
+ exec?(path: string, args: Record<string, any>, options: AFSExecOptions): Promise<AFSExecResult>;
239
+ stat?(path: string, options?: AFSStatOptions): Promise<AFSStatResult>;
240
+ explain?(path: string, options?: AFSExplainOptions): Promise<AFSExplainResult>;
241
+ }
242
+ /**
243
+ * Parameters for loading a module from configuration.
244
+ */
245
+ interface AFSModuleLoadParams {
246
+ /**
247
+ * Base path for resolving relative paths in configuration.
248
+ * Typically the directory containing the configuration file.
249
+ */
250
+ basePath?: string;
251
+ /**
252
+ * Parsed configuration object.
253
+ * The caller is responsible for parsing YAML/JSON/TOML into this object.
254
+ */
255
+ config?: object;
256
+ }
257
+ /**
258
+ * Mount configuration for a single provider.
259
+ * Used by ProviderRegistry and provider factories at runtime.
260
+ * The validated Zod schema version lives in @aigne/afs-cli (config file validation).
261
+ */
262
+ interface MountConfig {
263
+ /** Mount path */
264
+ path: string;
265
+ /** Provider URI (e.g., fs:///path, git:///repo?branch=main) */
266
+ uri: string;
267
+ /** Namespace for this mount */
268
+ namespace?: string;
269
+ /** Human/LLM readable description */
270
+ description?: string;
271
+ /** Access mode: readonly or readwrite */
272
+ access_mode?: AFSAccessMode;
273
+ /** Authentication string */
274
+ auth?: string;
275
+ /** Authorization token */
276
+ token?: string;
277
+ /** Provider-specific options */
278
+ options?: Record<string, unknown>;
279
+ }
280
+ /**
281
+ * Provider manifest — self-description of a provider's URI template, schema, and metadata.
282
+ *
283
+ * Declared via `static manifest()` on Provider class.
284
+ * Schema contains ALL provider parameters (path vars + options + sensitive).
285
+ * Parameter source is determined by rules:
286
+ * - Field in uriTemplate {} → extracted from URI body
287
+ * - Field with sensitive: true in schema → credential store
288
+ * - Everything else → config/query params
289
+ */
290
+ interface ProviderManifest {
291
+ /** Provider name */
292
+ name: string;
293
+ /** Human-readable description */
294
+ description: string;
295
+ /** URI template, e.g. "s3://{bucket}/{prefix+?}" */
296
+ uriTemplate: string;
297
+ /** Category (storage, database, cloud, compute, integration, ...) */
298
+ category: string;
299
+ /** Zod schema containing ALL parameters (path vars + options + sensitive) */
300
+ schema: ZodType;
301
+ /** Tags for discovery */
302
+ tags?: string[];
303
+ /** Use case descriptions */
304
+ useCases?: string[];
305
+ }
306
+ /**
307
+ * Interface for module classes that support schema validation and loading from configuration.
308
+ * This describes the static part of a module class.
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * class MyModule implements AFSModule {
313
+ * static schema() { return mySchema; }
314
+ * static async load(params: AFSModuleLoadParams) { ... }
315
+ * // ...
316
+ * }
317
+ *
318
+ * // Type check
319
+ * const _check: AFSModuleClass<MyModule, MyModuleOptions> = MyModule;
320
+ * ```
321
+ */
322
+ interface AFSModuleClass<T extends AFSModule = AFSModule, O extends object = object> {
323
+ /**
324
+ * Returns the Zod schema for validating module configuration.
325
+ * @deprecated Use `manifest()` instead — the manifest includes the schema
326
+ * along with URI template, category, and tags for unified provider loading.
327
+ */
328
+ schema(): ZodType<O>;
329
+ /**
330
+ * Returns provider manifest(s) describing URI template, schema, and metadata.
331
+ * Single manifest for most providers; array for multi-scheme providers (e.g., MCP).
332
+ */
333
+ manifest?(): ProviderManifest | ProviderManifest[];
334
+ /** Loads a module instance from configuration file path and parsed config */
335
+ load(params: AFSModuleLoadParams): Promise<T>;
336
+ /**
337
+ * Optional: Custom authentication flow for this provider.
338
+ * When present, called instead of the default schema-based collection.
339
+ * The context provides resolved fields and primitives (collect, createCallbackServer, requestOpenURL).
340
+ *
341
+ * @returns all collected fields (both sensitive and non-sensitive), or null if user declined
342
+ */
343
+ auth?(context: AuthContext): Promise<Record<string, unknown> | null>;
344
+ /** Constructor */
345
+ new (options: O): T;
346
+ }
347
+ interface AFSRoot extends AFSModule {
348
+ list(path: string, options?: AFSListOptions): Promise<AFSListResult>;
349
+ search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;
350
+ initializePhysicalPath(): Promise<string>;
351
+ cleanupPhysicalPath(): Promise<void>;
352
+ }
353
+ interface AFSEntryMetadata extends Record<string, any> {
354
+ /** Kind identifier (e.g., "afs:node", "chamber:project") */
355
+ kind?: string;
356
+ /**
357
+ * Kind inheritance chain, from most specific to most general.
358
+ * First element should match the `kind` field.
359
+ *
360
+ * Example: MCP tool has `kinds: ["mcp:tool", "afs:executable", "afs:node"]`
361
+ * Use for capability detection: `kinds.includes("afs:executable")`
362
+ *
363
+ * @example
364
+ * ```typescript
365
+ * // Check if node is executable
366
+ * const isExecutable = metadata.kinds?.includes("afs:executable") ?? false;
367
+ * ```
368
+ */
369
+ kinds?: string[];
370
+ /**
371
+ * Number of children this node has.
372
+ * - undefined: leaf node / file (no children possible)
373
+ * - 0: directory with no children (empty container)
374
+ * - N (N > 0): directory with exactly N children
375
+ * - -1: directory with children, but count unknown (lazy loading)
376
+ *
377
+ * Note: This is a runtime value computed by Provider. There is no file/directory
378
+ * distinction in AFS — all nodes can potentially have children.
379
+ *
380
+ * Design: undefined defaults to "leaf" for safety — if a developer forgets
381
+ * to set childrenCount, the node is treated as a leaf (safe failure).
382
+ * Directory nodes whose children count is not yet known should use -1.
383
+ */
384
+ childrenCount?: number;
385
+ /** File size in bytes (for content nodes) */
386
+ size?: number;
387
+ /** Human-readable description */
388
+ description?: string;
389
+ }
390
+ interface AFSEntry<T = any> {
391
+ id: string;
392
+ createdAt?: Date;
393
+ updatedAt?: Date;
394
+ path: string;
395
+ agentId?: string | null;
396
+ userId?: string | null;
397
+ sessionId?: string | null;
398
+ summary?: string | null;
399
+ meta?: AFSEntryMetadata | null;
400
+ linkTo?: string | null;
401
+ content?: T;
402
+ /**
403
+ * Available actions for this entry.
404
+ * Actions can be executed via the `/.actions/<action-name>` path.
405
+ * Each action uses `afs:executable` kind.
406
+ */
407
+ actions?: ActionSummary[];
408
+ }
409
+ /**
410
+ * Zod schema for ActionSummary validation.
411
+ */
412
+ declare const actionSummarySchema: z.ZodObject<{
413
+ name: z.ZodString;
414
+ description: z.ZodOptional<z.ZodString>;
415
+ inputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
416
+ }, z.core.$strip>;
417
+ declare const afsEntrySchema: ZodType<AFSEntry>;
418
+ //#endregion
419
+ export { AFSAccessMode, AFSActionResult, AFSChangeListener, AFSChangeRecord, AFSDeleteOptions, AFSDeleteResult, AFSEntry, AFSEntryMetadata, AFSExecOptions, AFSExecResult, AFSExplainOptions, AFSListOptions, AFSListResult, AFSModule, AFSModuleClass, AFSModuleLoadParams, AFSOperationOptions, AFSReadOptions, AFSReadResult, AFSRenameOptions, AFSRenameResult, AFSRoot, AFSSearchOptions, AFSSearchResult, AFSStatOptions, AFSStatResult, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult, ActionSummary, AuthContext, CallbackServer, MountConfig, ProviderManifest, accessModeSchema, actionSummarySchema, afsEntrySchema };
420
+ //# sourceMappingURL=type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.mts","names":[],"sources":["../src/type.ts"],"mappings":";;;;;;;;AAaA;;;UAAiB,WAAA;EAaC;EAAA,SAXP,QAAA,EAAU,MAAA;EAWW;;;;;;;;;EAA9B,OAAA,CAAQ,MAAA,EAAQ,WAAA,GAAc,OAAA,CAAQ,MAAA;EAA9B;;;;EAMR,oBAAA,IAAwB,OAAA,CAAQ,cAAA;EAAA;;;;EAMhC,cAAA,CAAe,GAAA,UAAa,OAAA,WAAkB,OAAA;AAAA;;AAOhD;;;UAAiB,cAAA;EAEf;EAAA,WAAA;EAG4B;EAA5B,eAAA,CAAgB,OAAA;IAAY,OAAA;EAAA,IAAqB,OAAA,CAAQ,MAAA;EAGzD;EAAA,KAAA;AAAA;AAIF;AAAA,UAAiB,eAAA;EACf,IAAA;EACA,IAAA;EADA;EAGA,UAAA;EAAA;EAEA,SAAA;EACA,SAAA;EAEA;EAAA,IAAA,GAAO,MAAA;AAAA;;KAIG,iBAAA,IAAqB,KAAA,EAAO,eAAA;;;;;AAOxC;KAAY,aAAA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AuB,OAAA;AAAA;AAAA,UAGR,gBAAA,SAAyB,MAAA;EA9HqC;EAgI7E,IAAA;EA1He;;;;;AAkBjB;;;;;;;;EAsHE,KAAA;EA5Gc;;;;;;;AAmBhB;;;;;;;EAwGE,aAAA;EA9FA;EAgGA,IAAA;EA9FA;EAgGA,WAAA;AAAA;AAAA,UAIe,QAAA;EACf,EAAA;EACA,SAAA,GAAY,IAAA;EACZ,SAAA,GAAY,IAAA;EACZ,IAAA;EACA,OAAA;EACA,MAAA;EACA,SAAA;EACA,OAAA;EACA,IAAA,GAAO,gBAAA;EACP,MAAA;EACA,OAAA,GAAU,CAAA;EA3EyB;;;;;EAiFnC,OAAA,GAAU,aAAA;AAAA;;;;cAMC,mBAAA,EAAmB,CAAA,CAAA,SAAA;;;;;cAMnB,cAAA,EAAgB,OAAA,CAAQ,QAAA"}
package/dist/type.mjs ADDED
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/type.ts
4
+ /**
5
+ * Zod schema for access mode validation.
6
+ * Can be reused across modules that support access mode configuration.
7
+ */
8
+ const accessModeSchema = z.enum(["readonly", "readwrite"]).optional();
9
+ /**
10
+ * Zod schema for ActionSummary validation.
11
+ */
12
+ const actionSummarySchema = z.object({
13
+ name: z.string(),
14
+ description: z.string().optional(),
15
+ inputSchema: z.record(z.string(), z.any()).optional()
16
+ });
17
+ const afsEntrySchema = z.object({
18
+ id: z.string(),
19
+ createdAt: z.date().optional(),
20
+ updatedAt: z.date().optional(),
21
+ path: z.string(),
22
+ userId: z.string().nullable().optional(),
23
+ sessionId: z.string().nullable().optional(),
24
+ summary: z.string().nullable().optional(),
25
+ meta: z.record(z.string(), z.any()).nullable().optional(),
26
+ linkTo: z.string().nullable().optional(),
27
+ content: z.any().optional(),
28
+ actions: z.array(actionSummarySchema).optional()
29
+ });
30
+
31
+ //#endregion
32
+ export { accessModeSchema, actionSummarySchema, afsEntrySchema };
33
+ //# sourceMappingURL=type.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.mjs","names":[],"sources":["../src/type.ts"],"sourcesContent":["import { type ZodType, z } from \"zod\";\nimport type { AFSExplainResult, JSONSchema7 } from \"./meta/type.js\";\n\n// =============================================================================\n// AUTH CONTEXT TYPES\n// =============================================================================\n\n/**\n * Abstract auth context interface for collecting credentials.\n * Implementations:\n * - CLI: terminal prompt / masked input / open command\n * - MCP: elicitation form mode / URL mode\n */\nexport interface AuthContext {\n /** Step 2 resolved fields (env/store/config), so auth() can skip already-resolved fields */\n readonly resolved: Record<string, unknown>;\n\n /**\n * Collect fields from the user.\n * Implementation auto-selects secure channel based on `sensitive` markers in schema:\n * - All non-sensitive → MCP form mode / CLI prompt\n * - Contains sensitive → MCP URL mode (local HTTP form) / CLI masked input\n *\n * @param schema - JSON Schema describing fields to collect (from z.toJSONSchema() or manifest)\n * @returns collected values, or null if user declined/cancelled\n */\n collect(schema: JSONSchema7): Promise<Record<string, unknown> | null>;\n\n /**\n * Create a localhost callback server for OAuth redirect_uri flows.\n * Provider uses callbackURL to construct auth URL, then waitForCallback() for the result.\n */\n createCallbackServer(): Promise<CallbackServer>;\n\n /**\n * Request the client to open a URL (MCP: URL mode elicitation, CLI: open command).\n * Only opens — does not wait for data.\n */\n requestOpenURL(url: string, message: string): Promise<\"accepted\" | \"declined\" | \"cancelled\">;\n}\n\n/**\n * Localhost callback server for OAuth flows.\n * Created by AuthContext.createCallbackServer().\n */\nexport interface CallbackServer {\n /** Callback address, e.g. http://127.0.0.1:{port}/callback */\n callbackURL: string;\n\n /** Wait for a callback request. Returns query params, or null on timeout/cancel. */\n waitForCallback(options?: { timeout?: number }): Promise<Record<string, string> | null>;\n\n /** Close the callback server. Idempotent. */\n close(): void;\n}\n\n/** AFS change record — pure data, zero external dependencies */\nexport interface AFSChangeRecord {\n kind: \"write\" | \"delete\" | \"mount\" | \"unmount\" | \"rename\";\n path: string;\n /** Module name (for mount/unmount events) */\n moduleName?: string;\n /** Namespace (for mount/unmount events) */\n namespace?: string | null;\n timestamp: number;\n /** Optional metadata — AFS passes through without interpretation */\n meta?: Record<string, unknown>;\n}\n\n/** Change listener — injected by AOS, called by AFS */\nexport type AFSChangeListener = (event: AFSChangeRecord) => void;\n\n/**\n * Access mode for AFS modules and root.\n * - \"readonly\": Only read operations are allowed (list, read, search)\n * - \"readwrite\": All operations are allowed\n */\nexport type AFSAccessMode = \"readonly\" | \"readwrite\";\n\n/**\n * Zod schema for access mode validation.\n * Can be reused across modules that support access mode configuration.\n */\nexport const accessModeSchema = z.enum([\"readonly\", \"readwrite\"] as const).optional();\n\nexport interface AFSOperationOptions {\n context?: any;\n}\n\nexport interface AFSListOptions extends AFSOperationOptions {\n filter?: {\n agentId?: string;\n userId?: string;\n sessionId?: string;\n before?: string;\n after?: string;\n };\n maxDepth?: number;\n /**\n * Number of entries to skip (pagination offset)\n * @default 0\n */\n offset?: number;\n /**\n * Maximum number of entries to return\n * @default 1000\n */\n limit?: number;\n orderBy?: [string, \"asc\" | \"desc\"][];\n maxChildren?: number;\n onOverflow?: \"truncate\";\n /**\n * Whether to disable .gitignore files when listing files.\n * @default false\n */\n disableGitignore?: boolean;\n /**\n * Glob pattern to filter entries by path.\n * Examples: \"*.ts\", \"**\\/*.js\", \"src/**\\/*.{ts,tsx}\"\n */\n pattern?: string;\n}\n\nexport interface AFSListResult {\n data: AFSEntry[];\n message?: string;\n /**\n * Total count of entries (optional)\n * - If present: indicates complete dataset size (data may be a subset)\n * - If absent (undefined): data IS the complete result, total === data.length\n */\n total?: number;\n}\n\nexport interface AFSSearchOptions extends AFSOperationOptions {\n limit?: number;\n caseSensitive?: boolean;\n}\n\nexport interface AFSSearchResult {\n data: AFSEntry[];\n message?: string;\n}\n\nexport interface AFSReadOptions extends AFSOperationOptions {\n filter?: AFSListOptions[\"filter\"];\n}\n\nexport interface AFSReadResult {\n data?: AFSEntry;\n message?: string;\n}\n\nexport interface AFSDeleteOptions extends AFSOperationOptions {\n recursive?: boolean;\n}\n\nexport interface AFSDeleteResult {\n message?: string;\n}\n\nexport interface AFSRenameOptions extends AFSOperationOptions {\n overwrite?: boolean;\n}\n\nexport interface AFSRenameResult {\n message?: string;\n}\n\nexport interface AFSWriteOptions extends AFSOperationOptions {\n append?: boolean;\n}\n\nexport interface AFSWriteResult {\n data: AFSEntry;\n message?: string;\n}\n\nexport interface AFSWriteEntryPayload extends Omit<AFSEntry, \"id\" | \"path\"> {}\n\nexport interface AFSExecOptions extends AFSOperationOptions {}\n\nexport interface AFSExecResult extends AFSActionResult {}\n\n/**\n * Summary information for an action available on a node.\n * Used in AFSEntry.actions to describe available actions.\n */\nexport interface ActionSummary {\n /** The action name (e.g., \"refresh\", \"export\", \"delete\") */\n name: string;\n /** Human-readable description of what the action does */\n description?: string;\n /** JSON Schema for input parameters */\n inputSchema?: JSONSchema7;\n}\n\n/**\n * Result from executing an action via the Action System.\n * Actions return structured results with success/failure status.\n */\nexport interface AFSActionResult {\n /** Whether the action completed successfully */\n success: boolean;\n /** Data returned by the action on success */\n data?: Record<string, unknown>;\n /** Error information when success is false */\n error?: {\n /** Error code (e.g., \"VALIDATION_ERROR\", \"NOT_FOUND\") */\n code: string;\n /** Human-readable error message */\n message: string;\n /** Additional error details */\n details?: Record<string, unknown>;\n };\n}\n\nexport interface AFSStatOptions extends AFSOperationOptions {}\n\n/**\n * Result from stat operation.\n * The data field follows AFSEntry structure but without content.\n */\nexport interface AFSStatResult {\n data?: Omit<AFSEntry, \"content\">;\n message?: string;\n}\n\nexport interface AFSExplainOptions extends AFSOperationOptions {\n format?: \"markdown\" | \"text\";\n}\n\nexport interface AFSModule {\n readonly name: string;\n\n readonly description?: string;\n\n /**\n * The complete source URI for this provider instance (including query params).\n * Set by ProviderRegistry factories after creating the provider.\n * Used by loadProvider injection to persist mount configuration.\n */\n readonly uri?: string;\n\n /**\n * Access mode for this module.\n * - \"readonly\": Only read operations are allowed\n * - \"readwrite\": All operations are allowed\n * Default behavior is implementation-specific.\n */\n readonly accessMode?: AFSAccessMode;\n\n /**\n * Enable automatic agent skill scanning for this module.\n * When set to true, the system will scan this module for agent skills.\n * @default false\n */\n readonly agentSkills?: boolean;\n\n /**\n * Timeout in milliseconds for provider operations.\n * Currently used for mount check.\n * If not specified, uses the default value (10s).\n * Remote providers (MCP, HTTP) may need longer timeouts.\n */\n readonly timeout?: number;\n\n onMount?(root: AFSRoot, mountPath?: string): void;\n\n symlinkToPhysical?(path: string): Promise<void>;\n\n list?(path: string, options?: AFSListOptions): Promise<AFSListResult>;\n\n read?(path: string, options?: AFSReadOptions): Promise<AFSReadResult>;\n\n write?(\n path: string,\n content: AFSWriteEntryPayload,\n options?: AFSWriteOptions,\n ): Promise<AFSWriteResult>;\n\n delete?(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult>;\n\n rename?(oldPath: string, newPath: string, options?: AFSRenameOptions): Promise<AFSRenameResult>;\n\n search?(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;\n\n exec?(path: string, args: Record<string, any>, options: AFSExecOptions): Promise<AFSExecResult>;\n\n stat?(path: string, options?: AFSStatOptions): Promise<AFSStatResult>;\n\n explain?(path: string, options?: AFSExplainOptions): Promise<AFSExplainResult>;\n}\n\n/**\n * Parameters for loading a module from configuration.\n */\nexport interface AFSModuleLoadParams {\n /**\n * Base path for resolving relative paths in configuration.\n * Typically the directory containing the configuration file.\n */\n basePath?: string;\n /**\n * Parsed configuration object.\n * The caller is responsible for parsing YAML/JSON/TOML into this object.\n */\n config?: object;\n}\n\n/**\n * Mount configuration for a single provider.\n * Used by ProviderRegistry and provider factories at runtime.\n * The validated Zod schema version lives in @aigne/afs-cli (config file validation).\n */\nexport interface MountConfig {\n /** Mount path */\n path: string;\n /** Provider URI (e.g., fs:///path, git:///repo?branch=main) */\n uri: string;\n /** Namespace for this mount */\n namespace?: string;\n /** Human/LLM readable description */\n description?: string;\n /** Access mode: readonly or readwrite */\n access_mode?: AFSAccessMode;\n /** Authentication string */\n auth?: string;\n /** Authorization token */\n token?: string;\n /** Provider-specific options */\n options?: Record<string, unknown>;\n}\n\n/**\n * Provider manifest — self-description of a provider's URI template, schema, and metadata.\n *\n * Declared via `static manifest()` on Provider class.\n * Schema contains ALL provider parameters (path vars + options + sensitive).\n * Parameter source is determined by rules:\n * - Field in uriTemplate {} → extracted from URI body\n * - Field with sensitive: true in schema → credential store\n * - Everything else → config/query params\n */\nexport interface ProviderManifest {\n /** Provider name */\n name: string;\n /** Human-readable description */\n description: string;\n /** URI template, e.g. \"s3://{bucket}/{prefix+?}\" */\n uriTemplate: string;\n /** Category (storage, database, cloud, compute, integration, ...) */\n category: string;\n /** Zod schema containing ALL parameters (path vars + options + sensitive) */\n schema: ZodType;\n /** Tags for discovery */\n tags?: string[];\n /** Use case descriptions */\n useCases?: string[];\n}\n\n/**\n * Interface for module classes that support schema validation and loading from configuration.\n * This describes the static part of a module class.\n *\n * @example\n * ```typescript\n * class MyModule implements AFSModule {\n * static schema() { return mySchema; }\n * static async load(params: AFSModuleLoadParams) { ... }\n * // ...\n * }\n *\n * // Type check\n * const _check: AFSModuleClass<MyModule, MyModuleOptions> = MyModule;\n * ```\n */\nexport interface AFSModuleClass<T extends AFSModule = AFSModule, O extends object = object> {\n /**\n * Returns the Zod schema for validating module configuration.\n * @deprecated Use `manifest()` instead — the manifest includes the schema\n * along with URI template, category, and tags for unified provider loading.\n */\n schema(): ZodType<O>;\n\n /**\n * Returns provider manifest(s) describing URI template, schema, and metadata.\n * Single manifest for most providers; array for multi-scheme providers (e.g., MCP).\n */\n manifest?(): ProviderManifest | ProviderManifest[];\n\n /** Loads a module instance from configuration file path and parsed config */\n load(params: AFSModuleLoadParams): Promise<T>;\n\n /**\n * Optional: Custom authentication flow for this provider.\n * When present, called instead of the default schema-based collection.\n * The context provides resolved fields and primitives (collect, createCallbackServer, requestOpenURL).\n *\n * @returns all collected fields (both sensitive and non-sensitive), or null if user declined\n */\n auth?(context: AuthContext): Promise<Record<string, unknown> | null>;\n\n /** Constructor */\n new (options: O): T;\n}\n\nexport interface AFSRoot extends AFSModule {\n list(path: string, options?: AFSListOptions): Promise<AFSListResult>;\n\n search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;\n\n initializePhysicalPath(): Promise<string>;\n\n cleanupPhysicalPath(): Promise<void>;\n}\n\nexport interface AFSEntryMetadata extends Record<string, any> {\n /** Kind identifier (e.g., \"afs:node\", \"chamber:project\") */\n kind?: string;\n /**\n * Kind inheritance chain, from most specific to most general.\n * First element should match the `kind` field.\n *\n * Example: MCP tool has `kinds: [\"mcp:tool\", \"afs:executable\", \"afs:node\"]`\n * Use for capability detection: `kinds.includes(\"afs:executable\")`\n *\n * @example\n * ```typescript\n * // Check if node is executable\n * const isExecutable = metadata.kinds?.includes(\"afs:executable\") ?? false;\n * ```\n */\n kinds?: string[];\n /**\n * Number of children this node has.\n * - undefined: leaf node / file (no children possible)\n * - 0: directory with no children (empty container)\n * - N (N > 0): directory with exactly N children\n * - -1: directory with children, but count unknown (lazy loading)\n *\n * Note: This is a runtime value computed by Provider. There is no file/directory\n * distinction in AFS — all nodes can potentially have children.\n *\n * Design: undefined defaults to \"leaf\" for safety — if a developer forgets\n * to set childrenCount, the node is treated as a leaf (safe failure).\n * Directory nodes whose children count is not yet known should use -1.\n */\n childrenCount?: number;\n /** File size in bytes (for content nodes) */\n size?: number;\n /** Human-readable description */\n description?: string;\n // User-defined meta fields from .afs/meta.yaml are spread directly into this object\n}\n\nexport interface AFSEntry<T = any> {\n id: string;\n createdAt?: Date;\n updatedAt?: Date;\n path: string;\n agentId?: string | null;\n userId?: string | null;\n sessionId?: string | null;\n summary?: string | null;\n meta?: AFSEntryMetadata | null;\n linkTo?: string | null;\n content?: T;\n /**\n * Available actions for this entry.\n * Actions can be executed via the `/.actions/<action-name>` path.\n * Each action uses `afs:executable` kind.\n */\n actions?: ActionSummary[];\n}\n\n/**\n * Zod schema for ActionSummary validation.\n */\nexport const actionSummarySchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n inputSchema: z.record(z.string(), z.any()).optional(),\n});\n\nexport const afsEntrySchema: ZodType<AFSEntry> = z.object({\n id: z.string(),\n createdAt: z.date().optional(),\n updatedAt: z.date().optional(),\n path: z.string(),\n userId: z.string().nullable().optional(),\n sessionId: z.string().nullable().optional(),\n summary: z.string().nullable().optional(),\n meta: z.record(z.string(), z.any()).nullable().optional(),\n linkTo: z.string().nullable().optional(),\n content: z.any().optional(),\n actions: z.array(actionSummarySchema).optional(),\n});\n\n// Re-export meta types for backward compatibility\nexport type {\n AFSExplainResult,\n JSONSchema7,\n KindSchema,\n MetaPathInfo,\n NodeConstraint,\n NodesConstraints,\n ValidationError,\n ValidationResult,\n} from \"./meta/type.js\";\n"],"mappings":";;;;;;;AAmFA,MAAa,mBAAmB,EAAE,KAAK,CAAC,YAAY,YAAY,CAAU,CAAC,UAAU;;;;AA4YrF,MAAa,sBAAsB,EAAE,OAAO;CAC1C,MAAM,EAAE,QAAQ;CAChB,aAAa,EAAE,QAAQ,CAAC,UAAU;CAClC,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC,UAAU;CACtD,CAAC;AAEF,MAAa,iBAAoC,EAAE,OAAO;CACxD,IAAI,EAAE,QAAQ;CACd,WAAW,EAAE,MAAM,CAAC,UAAU;CAC9B,WAAW,EAAE,MAAM,CAAC,UAAU;CAC9B,MAAM,EAAE,QAAQ;CAChB,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CACxC,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CAC3C,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CACzC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU;CACzD,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CACxC,SAAS,EAAE,KAAK,CAAC,UAAU;CAC3B,SAAS,EAAE,MAAM,oBAAoB,CAAC,UAAU;CACjD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"camelize.d.cts","names":[],"sources":["../../src/utils/camelize.ts"],"mappings":";KAAY,SAAA,qBAA8B,CAAA,mDACnC,EAAA,GAAK,SAAA,CAAU,EAAA,IAAM,SAAA,CAAU,EAAA,MAClC,CAAA;AAAA,KAEQ,cAAA,+BACE,CAAA,IAAK,YAAA,CAAa,SAAA,UAAmB,CAAA,KAAM,CAAA,CAAE,CAAA,UAAW,IAAA,GAChE,CAAA,CAAE,CAAA,IACF,CAAA,CAAE,CAAA,UAAW,MAAA,GACX,CAAA,CAAE,CAAA,IACF,CAAA,CAAE,CAAA,UAAW,KAAA,YAAA,CAAA,8BAET,KAAA,CAAM,cAAA,CAAe,CAAA,KACrB,CAAA,CAAE,CAAA,IACJ,CAAA,CAAE,CAAA,+BACA,CAAA,gBACE,CAAA,CAAE,CAAA,IACF,cAAA,CAAe,CAAA,CAAE,CAAA,KACnB,CAAA,CAAE,CAAA;AAAA,KAGF,QAAA,iBAAyB,CAAA,SAAU,KAAA,YAC3C,KAAA,CAAM,cAAA,CAAe,CAAA,EAAG,CAAA,KACxB,cAAA,CAAe,CAAA,EAAG,CAAA;AAAA,iBAEN,QAAA,8BAAA,CAAA,GAAA,EACT,CAAA,EAAA,OAAA,GACK,CAAA,GACT,CAAA,2BAA4B,QAAA,CAAS,CAAA,EAAG,CAAA;AAAA,iBAI3B,SAAA,8BAAA,CAAA,GAAA,EACT,CAAA,EAAA,OAAA,GACK,CAAA,GACT,CAAA"}
1
+ {"version":3,"file":"camelize.d.cts","names":[],"sources":["../../src/utils/camelize.ts"],"mappings":";KAAY,SAAA,qBAA8B,CAAA,mDACnC,EAAA,GAAK,SAAA,CAAU,EAAA,IAAM,SAAA,CAAU,EAAA,MAClC,CAAA;AAAA,KAEQ,cAAA,+BACE,CAAA,IAAK,YAAA,CAAa,SAAA,UAAmB,CAAA,KAAM,CAAA,CAAE,CAAA,UAAW,IAAA,GAChE,CAAA,CAAE,CAAA,IACF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,0 +1,129 @@
1
+
2
+ //#region src/utils/schema.ts
3
+ /**
4
+ * Extract the list of top-level property names marked as sensitive.
5
+ *
6
+ * Works with both flat schemas and nested schemas (e.g. credentials.accessKeyId).
7
+ * For nested objects, returns dot-notation paths (e.g. "credentials.accessKeyId").
8
+ *
9
+ * @param schema - JSON Schema (from z.toJSONSchema() or manifest schema)
10
+ * @returns array of sensitive field paths
11
+ */
12
+ function getSensitiveFields(schema) {
13
+ const result = [];
14
+ collectSensitiveFields(schema, "", result);
15
+ return result;
16
+ }
17
+ function collectSensitiveFields(schema, prefix, result) {
18
+ if (typeof schema !== "object" || schema === null) return;
19
+ const properties = schema.properties;
20
+ if (!properties || typeof properties !== "object") return;
21
+ for (const [key, propSchema] of Object.entries(properties)) {
22
+ const prop = propSchema;
23
+ const fieldPath = prefix ? `${prefix}.${key}` : key;
24
+ if (prop.sensitive === true) result.push(fieldPath);
25
+ if (prop.type === "object" && prop.properties) collectSensitiveFields(prop, fieldPath, result);
26
+ }
27
+ }
28
+ /**
29
+ * Extract environment variable mappings from a JSON Schema.
30
+ *
31
+ * Returns a map from field path to array of env variable names.
32
+ * Only includes fields that have `env` metadata set.
33
+ *
34
+ * @param schema - JSON Schema (from z.toJSONSchema() or manifest schema)
35
+ * @returns map of field path → env variable names
36
+ */
37
+ function getEnvMappings(schema) {
38
+ const result = {};
39
+ collectEnvMappings(schema, "", result);
40
+ return result;
41
+ }
42
+ function collectEnvMappings(schema, prefix, result) {
43
+ if (typeof schema !== "object" || schema === null) return;
44
+ const properties = schema.properties;
45
+ if (!properties || typeof properties !== "object") return;
46
+ for (const [key, propSchema] of Object.entries(properties)) {
47
+ const prop = propSchema;
48
+ const fieldPath = prefix ? `${prefix}.${key}` : key;
49
+ if (Array.isArray(prop.env) && prop.env.length > 0) result[fieldPath] = prop.env;
50
+ if (prop.type === "object" && prop.properties) collectEnvMappings(prop, fieldPath, result);
51
+ }
52
+ }
53
+ /**
54
+ * Resolve environment variables for schema fields that declare `env` metadata.
55
+ *
56
+ * For each field with env mapping, checks process.env for the first matching variable.
57
+ * Only returns fields where an env variable was found.
58
+ *
59
+ * @param schema - JSON Schema with env metadata
60
+ * @param env - Environment variables (defaults to process.env)
61
+ * @returns resolved field values from environment
62
+ */
63
+ function resolveEnvFromSchema(schema, env = process.env) {
64
+ const mappings = getEnvMappings(schema);
65
+ const resolved = {};
66
+ for (const [field, envVars] of Object.entries(mappings)) for (const envVar of envVars) {
67
+ const value = env[envVar];
68
+ if (value !== void 0 && value !== "") {
69
+ resolved[field] = value;
70
+ break;
71
+ }
72
+ }
73
+ return resolved;
74
+ }
75
+ /**
76
+ * Reserved key for passing sensitiveArgs annotations through mount.options.
77
+ * Used by CLI --sensitive-args and exec mount actions to annotate which
78
+ * user-provided options are sensitive (for ad-hoc schema construction).
79
+ */
80
+ const SENSITIVE_ARGS_KEY = "_sensitiveArgs";
81
+ /**
82
+ * Build an ad-hoc JSON Schema from user-provided key-value pairs and sensitiveArgs.
83
+ *
84
+ * Used when a provider has no native schema() and no registry manifest schema,
85
+ * e.g., generic MCP servers mounted via direct URI with extra options.
86
+ *
87
+ * @param values - Key-value pairs provided by the user
88
+ * @param sensitiveArgs - Field names that should be marked as sensitive
89
+ * @returns JSON Schema with properties derived from values
90
+ */
91
+ function buildAdHocSchema(values, sensitiveArgs = []) {
92
+ const sensitiveSet = new Set(sensitiveArgs);
93
+ const properties = {};
94
+ for (const [key, value] of Object.entries(values)) {
95
+ const prop = { type: typeof value === "number" ? "number" : typeof value === "boolean" ? "boolean" : "string" };
96
+ if (sensitiveSet.has(key)) prop.sensitive = true;
97
+ properties[key] = prop;
98
+ }
99
+ return {
100
+ type: "object",
101
+ properties
102
+ };
103
+ }
104
+ /**
105
+ * Separate values into sensitive and non-sensitive groups based on schema metadata.
106
+ *
107
+ * @param schema - JSON Schema with sensitive metadata
108
+ * @param values - Values to separate
109
+ * @returns object with `sensitive` and `nonSensitive` value groups
110
+ */
111
+ function separateSensitiveValues(schema, values) {
112
+ const sensitiveFields = new Set(getSensitiveFields(schema));
113
+ const sensitive = {};
114
+ const nonSensitive = {};
115
+ for (const [key, value] of Object.entries(values)) if (sensitiveFields.has(key)) sensitive[key] = String(value);
116
+ else nonSensitive[key] = value;
117
+ return {
118
+ sensitive,
119
+ nonSensitive
120
+ };
121
+ }
122
+
123
+ //#endregion
124
+ exports.SENSITIVE_ARGS_KEY = SENSITIVE_ARGS_KEY;
125
+ exports.buildAdHocSchema = buildAdHocSchema;
126
+ exports.getEnvMappings = getEnvMappings;
127
+ exports.getSensitiveFields = getSensitiveFields;
128
+ exports.resolveEnvFromSchema = resolveEnvFromSchema;
129
+ exports.separateSensitiveValues = separateSensitiveValues;