@cldmv/slothlet-types 3.15.3 → 3.16.1

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 (58) hide show
  1. package/lib/builders/api-assignment.d.mts +125 -4
  2. package/lib/builders/api_builder.d.mts +104 -7
  3. package/lib/builders/builder.d.mts +82 -1
  4. package/lib/builders/modes-processor.d.mts +66 -3
  5. package/lib/errors.d.mts +114 -19
  6. package/lib/factories/component-base.d.mts +171 -8
  7. package/lib/factories/context.d.mts +22 -4
  8. package/lib/handlers/api-cache-manager.d.mts +209 -20
  9. package/lib/handlers/api-manager.d.mts +539 -38
  10. package/lib/handlers/context-async.d.mts +92 -25
  11. package/lib/handlers/context-live.d.mts +117 -30
  12. package/lib/handlers/framework-internals.d.mts +33 -2
  13. package/lib/handlers/hook-manager.d.mts +306 -73
  14. package/lib/handlers/lifecycle-token.d.mts +48 -3
  15. package/lib/handlers/lifecycle.d.mts +86 -5
  16. package/lib/handlers/materialize-manager.d.mts +76 -8
  17. package/lib/handlers/metadata.d.mts +238 -18
  18. package/lib/handlers/module-manager.d.mts +169 -21
  19. package/lib/handlers/ownership.d.mts +376 -45
  20. package/lib/handlers/permission-manager.d.mts +283 -46
  21. package/lib/handlers/routine-manager.d.mts +425 -0
  22. package/lib/handlers/trusted-root.d.mts +45 -4
  23. package/lib/handlers/unified-wrapper.d.mts +287 -26
  24. package/lib/handlers/version-manager.d.mts +236 -29
  25. package/lib/helpers/caller-pinning.d.mts +21 -2
  26. package/lib/helpers/class-instance-wrapper.d.mts +56 -2
  27. package/lib/helpers/config.d.mts +311 -161
  28. package/lib/helpers/defaults.d.mts +39 -0
  29. package/lib/helpers/eventemitter-context.d.mts +29 -3
  30. package/lib/helpers/eventtarget-context.d.mts +19 -1
  31. package/lib/helpers/eventtarget-property-context.d.mts +21 -0
  32. package/lib/helpers/generate-manifest.d.mts +174 -7
  33. package/lib/helpers/hint-detector.d.mts +22 -2
  34. package/lib/helpers/manifest-resolver.d.mts +100 -1
  35. package/lib/helpers/modes-utils.d.mts +30 -3
  36. package/lib/helpers/module-discovery.d.mts +80 -7
  37. package/lib/helpers/module-manifest-validator.d.mts +36 -13
  38. package/lib/helpers/module-sort.d.mts +64 -1
  39. package/lib/helpers/observer-context.d.mts +21 -0
  40. package/lib/helpers/pattern-matcher.d.mts +43 -3
  41. package/lib/helpers/platform.d.mts +109 -10
  42. package/lib/helpers/resolve-from-caller.d.mts +27 -3
  43. package/lib/helpers/sanitize.d.mts +92 -4
  44. package/lib/helpers/scheduler-context.d.mts +21 -1
  45. package/lib/helpers/utilities.d.mts +52 -4
  46. package/lib/i18n/translations.d.mts +50 -5
  47. package/lib/modes/eager.d.mts +46 -8
  48. package/lib/modes/lazy.d.mts +57 -10
  49. package/lib/processors/flatten.d.mts +116 -56
  50. package/lib/processors/loader.d.mts +77 -10
  51. package/lib/processors/type-generator.d.mts +16 -2
  52. package/lib/processors/typescript.d.mts +169 -13
  53. package/lib/runtime/runtime-asynclocalstorage.d.mts +71 -3
  54. package/lib/runtime/runtime-livebindings.d.mts +37 -2
  55. package/lib/runtime/runtime.d.mts +39 -3
  56. package/lib/typegen/typegen.d.mts +34 -2
  57. package/package.json +5 -23
  58. package/slothlet.d.mts +428 -3
@@ -1,26 +1,246 @@
1
- export const MODULE_ID_SEPARATOR: "__slothlet_sep__";
1
+ /**
2
+ * Internal delimiter joining a module's id and apiPath in the composite `moduleID` metadata key
3
+ * (`` `${moduleID}${MODULE_ID_SEPARATOR}${apiPath}` ``). Deliberately a readable, slothlet-branded
4
+ * multi-character token rather than a lone `:` — a `:` is common in real module ids (a `vine:abc`
5
+ * namespacing convention, the internal `versionDispatcher:<path>` id), and using it as the splitter
6
+ * made those ids un-round-trippable. A moduleID containing this token is refused at `add()`, so the
7
+ * composite is always unambiguous to split.
8
+ * @type {string}
9
+ * @internal
10
+ */
11
+ export const MODULE_ID_SEPARATOR: string;
12
+ /**
13
+ * Metadata handler for introspection of function metadata
14
+ * @class Metadata
15
+ * @extends ComponentBase
16
+ * @package
17
+ */
2
18
  export class Metadata extends ComponentBase {
3
19
  static slothletProperty: string;
4
- _instanceId: null;
5
- tagSystemMetadata(target: any, systemData: any, token: any): void;
6
- getSystemMetadata(target: any): any;
7
- getMetadata(target: any): any;
8
- setGlobalMetadata(key: any, value: any): void;
9
- setUserMetadata(target: any, key: any, value: any): void;
10
- removeUserMetadata(target: any, key: any): void;
11
- registerUserMetadata(identifier: any, metadata: any): void;
12
- removeUserMetadataByApiPath(apiPath: any): void;
13
- setPathMetadata(apiPath: any, keyOrObj: any, value: any): void;
14
- getPathMetadata(apiPath: any): any;
15
- removePathMetadata(apiPath: any, key: any): void;
20
+ /**
21
+ * Create Metadata instance
22
+ * @param {Object} slothlet - Slothlet instance
23
+ */
24
+ constructor(slothlet: Object);
25
+ /** @type {string | null} */
26
+ _instanceId: string | null;
27
+ /**
28
+ * Tag system metadata (SECURE, IMMUTABLE)
29
+ * Called internally during wrapper/function creation
30
+ *
31
+ * The `token` parameter must be the module-private `LIFECYCLE_TOKEN` Symbol exported
32
+ * from `@cldmv/slothlet/handlers/lifecycle-token`. Because a Symbol is a unique,
33
+ * non-forgeable value within a Node.js process, and because the token module is not
34
+ * listed in the package's public `exports` map, user-land code cannot construct a
35
+ * value that satisfies the `token === LIFECYCLE_TOKEN` check without modifying the
36
+ * source or importing an undocumented internal path.
37
+ *
38
+ * @param {Function|Object} target - Wrapper or function to tag
39
+ * @param {Object} systemData - System metadata (filePath, apiPath, moduleID, sourceFolder)
40
+ * @param {symbol} token - Must be `LIFECYCLE_TOKEN` — the unforgeable module-private Symbol
41
+ * @private
42
+ */
43
+ private tagSystemMetadata;
44
+ /**
45
+ * Get system metadata only (without user metadata)
46
+ * @param {Function|Object} target - Wrapper or function
47
+ * @returns {Object|null} System metadata or null
48
+ * @package
49
+ */
50
+ getSystemMetadata(target: Function | Object): Object | null;
51
+ /**
52
+ * Get metadata for a target (combines system + user)
53
+ * For wrappers: checks current impl to ensure metadata is current
54
+ * @param {Function|Object} target - Wrapper or function
55
+ * @returns {Object} Combined metadata (deeply frozen)
56
+ * @public
57
+ */
58
+ public getMetadata(target: Function | Object): Object;
59
+ /**
60
+ * Set global user metadata (applies to all functions)
61
+ * @param {string} key - Metadata key
62
+ * @param {unknown} value - Metadata value
63
+ * @public
64
+ */
65
+ public setGlobalMetadata(key: string, value: unknown): void;
66
+ /**
67
+ * Add/update user metadata for specific function
68
+ * @param {Function} target - Function to tag with metadata
69
+ * @param {string} key - Metadata key
70
+ * @param {unknown} value - Metadata value
71
+ * @public
72
+ */
73
+ public setUserMetadata(target: Function, key: string, value: unknown): void;
74
+ /**
75
+ * Remove user metadata from specific function
76
+ * @param {Function} target - Function to remove metadata from
77
+ * @param {string|string[]|Object<string, string[]>} [key] - Optional key(s) to remove (removes all if omitted). Can be:
78
+ * - string: Remove single key
79
+ * - string[]: Remove multiple keys (each element must be a string)
80
+ * - {key: string[]}: Remove nested keys from object values
81
+ * @public
82
+ */
83
+ public removeUserMetadata(target: Function, key?: string | string[] | {
84
+ [x: string]: string[];
85
+ }): void;
86
+ /**
87
+ * Register user metadata keyed by an identifier (moduleID or API path)
88
+ *
89
+ * @description
90
+ * Stores user-provided metadata in `#userMetadataStore` under the given
91
+ * `identifier`. The identifier is treated opaquely — callers pass either a
92
+ * generated moduleID (e.g. `base_slothlet`) or a dot-notation API path
93
+ * (e.g. `math`). `getMetadata()` retrieves entries using the same key via
94
+ * both the moduleID lookup and `collectMetadataFromParents`, so storing
95
+ * under a single key is sufficient for both cases.
96
+ *
97
+ * Multiple calls to the same identifier are merged; later calls override
98
+ * earlier scalar values, while nested plain objects merge recursively.
99
+ *
100
+ * @param {string} identifier - Module ID or dot-notation API path
101
+ * @param {Object} metadata - User metadata object to merge
102
+ * @package
103
+ */
104
+ registerUserMetadata(identifier: string, metadata: Object): void;
105
+ /**
106
+ * Remove all user metadata for an apiPath
107
+ *
108
+ * @description
109
+ * Cleanup method to remove all user metadata associated with an apiPath.
110
+ * Used during api.remove() or cleanup operations.
111
+ *
112
+ * @param {string} apiPath - API path to remove
113
+ * @package
114
+ */
115
+ removeUserMetadataByApiPath(apiPath: string): void;
116
+ /**
117
+ * Set metadata for all functions reachable at an API path.
118
+ *
119
+ * @description
120
+ * Stores metadata keyed by `apiPath` so that every function whose system
121
+ * `apiPath` starts with (or equals) the given path inherits the values via
122
+ * `collectMetadataFromParents()` in `getMetadata()`.
123
+ *
124
+ * Accepts either a single key/value pair or a plain object to merge.
125
+ * Multiple calls to the same path are merged; later calls override earlier
126
+ * ones for conflicting keys.
127
+ *
128
+ * Priority (lowest → highest): global → setForPath → set() → system.
129
+ *
130
+ * @param {string} apiPath - Dot-notation path (e.g. `"math"`, `"math.add"`)
131
+ * @param {string|Object} keyOrObj - Key string (with `value`) OR metadata object to merge
132
+ * @param {unknown} [value] - Value when `keyOrObj` is a string key
133
+ * @public
134
+ */
135
+ public setPathMetadata(apiPath: string, keyOrObj: string | Object, value?: unknown): void;
136
+ /**
137
+ * Get the user metadata collected from the path store for a given API path.
138
+ *
139
+ * @description
140
+ * Traverses from root segment to leaf, merging parent → child metadata — the same
141
+ * traversal used by `collectMetadataFromParents` inside `getMetadata()`. Does not
142
+ * include immutable system metadata; only user-supplied path store entries are returned.
143
+ *
144
+ * @param {string} apiPath - Dot-notation API path (e.g. `"v1.auth"`, `"math"`).
145
+ * @returns {Object} Merged user metadata for the path (not frozen).
146
+ * @public
147
+ * @example
148
+ * metadata.getPathMetadata("v1.auth"); // { stable: true, category: "auth" }
149
+ */
150
+ public getPathMetadata(apiPath: string): Object;
151
+ /**
152
+ * Remove metadata keys (or all metadata) for an API path.
153
+ *
154
+ * @description
155
+ * Removes one specific key, multiple keys, or ALL user metadata stored under
156
+ * the given `apiPath` key in the path store.
157
+ * Only affects metadata set via `setForPath()` / `registerUserMetadata()` for
158
+ * this exact path segment - it does not walk descendant paths.
159
+ *
160
+ * @param {string} apiPath - Dot-notation path (e.g. `"math"`, `"math.add"`)
161
+ * @param {string|string[]} [key] - Key(s) to remove. Omit to remove all metadata for the path.
162
+ * @public
163
+ */
164
+ public removePathMetadata(apiPath: string, key?: string | string[]): void;
165
+ /**
166
+ * Export user-managed metadata state for preservation across reload.
167
+ *
168
+ * @description
169
+ * Captures `#globalUserMetadata` and all entries in `#userMetadataStore`
170
+ * so they can be restored to a fresh Metadata instance after reload.
171
+ * Called by `slothlet.reload()` BEFORE `load()` destroys this instance.
172
+ *
173
+ * @returns {{ globalMetadata: Object, userMetadataStore: Map }} Snapshot of user state
174
+ * @package
175
+ */
16
176
  exportUserState(): {
17
- globalMetadata: any;
177
+ globalMetadata: Object;
18
178
  userMetadataStore: Map<any, any>;
19
179
  };
20
- importUserState(state: any): void;
21
- get(path: any): Promise<any>;
22
- self(): any;
23
- caller(): any;
180
+ /**
181
+ * Restore user-managed metadata state after a fresh load.
182
+ *
183
+ * @description
184
+ * Merges previously exported state into the new (empty) Metadata instance.
185
+ * Called by `slothlet.reload()` AFTER `load()` creates the new instance and
186
+ * BEFORE operation-history replay so that `registerUserMetadata()` from replay
187
+ * can properly merge over the restored base state.
188
+ *
189
+ * Merge priority: existing (from load) > saved state.
190
+ * This means replay-registered api.add metadata overrides restored values
191
+ * for the same key, which is the desired behaviour.
192
+ *
193
+ * @param {{ globalMetadata: Object, userMetadataStore: Map }} state - Previously exported state
194
+ * @package
195
+ */
196
+ importUserState(state: {
197
+ globalMetadata: Object;
198
+ userMetadataStore: Map<any, any>;
199
+ }): void;
200
+ /**
201
+ * Get metadata of any function by API path.
202
+ *
203
+ * Traverses `this.slothlet.api` using the dot-notation path, materializes
204
+ * lazy wrappers as needed, then returns the combined metadata for the
205
+ * resolved target via `getMetadata()`.
206
+ *
207
+ * Called by the `api.slothlet.metadata.get()` closure injected in
208
+ * `slothlet.injectRuntimeMetadataFunctions()`.
209
+ *
210
+ * @param {string} path - Dot-notation API path (e.g. `"math.add"`)
211
+ * @returns {Promise<object|null>} Combined metadata or null
212
+ * @public
213
+ */
214
+ public get(path: string): Promise<object | null>;
215
+ /**
216
+ * Get metadata for the currently-executing API function.
217
+ *
218
+ * Reads `currentWrapper` from the active context-manager store — the same
219
+ * fast synchronous path used by the unified wrapper's `apply` trap.
220
+ * Throws `RUNTIME_NO_ACTIVE_CONTEXT` when called outside of a slothlet
221
+ * execution context.
222
+ *
223
+ * Called by the `api.slothlet.metadata.self()` closure injected in
224
+ * `slothlet.injectRuntimeMetadataFunctions()`.
225
+ *
226
+ * @returns {object} Combined metadata for the current function
227
+ * @public
228
+ */
229
+ public self(): object;
230
+ /**
231
+ * Get metadata for the API function that called the current function.
232
+ *
233
+ * Reads `callerWrapper` from the active context-manager store.
234
+ * Returns `null` when there is no caller in context (e.g. the function
235
+ * was invoked directly from outside the API).
236
+ *
237
+ * Called by the `api.slothlet.metadata.caller()` closure injected in
238
+ * `slothlet.injectRuntimeMetadataFunctions()`.
239
+ *
240
+ * @returns {object|null} Combined metadata for the calling function, or null
241
+ * @public
242
+ */
243
+ public caller(): object | null;
24
244
  #private;
25
245
  }
26
246
  import { ComponentBase } from "#factories/component-base";
@@ -1,28 +1,176 @@
1
+ /**
2
+ * @typedef {import("../helpers/module-discovery.mjs").DiscoverResult} DiscoverResult
3
+ * @typedef {import("../helpers/module-discovery.mjs").DiscoverOptions} DiscoverOptions
4
+ */
5
+ /**
6
+ * @typedef {object} AddModuleOptions
7
+ * @property {"skip"|"warn"|"replace"|"merge"|"merge-replace"|"error"} [collisionMode="merge"] - Per-mount override; defaults to "merge" (matches `DEFAULT_MODULE_COLLISION_MODE`). Use "error" to throw on any pre-flight mountPath collision against api-manager's `addHistory`.
8
+ * @property {string} [version] - When the discovery cache holds multiple versions of the same `name`, mount only the entry whose package.json version matches.
9
+ * @property {DiscoverOptions} [discover] - Options to forward to the lazy discover() call if the cache is empty. Ignored when the cache already holds data.
10
+ */
11
+ /**
12
+ * @typedef {object} AddModulesOptions
13
+ * @property {"skip"|"warn"|"replace"|"merge"|"merge-replace"|"error"} [collisionMode="merge"] - Per-call collision policy passed to every mount. Defaults to "merge" (matches `DEFAULT_MODULE_COLLISION_MODE`); use "error" to throw on any pre-flight mountPath collision.
14
+ * @property {"throw"|"rollback"|"best-effort"} [onFailure="throw"] - Failure policy. `throw` (default): throw on first failure, leave mounted entries in place. `rollback`: throw on first failure, remove every entry mounted in this call. `best-effort`: collect failures, return aggregate `{ mounted, failed }`.
15
+ * @property {number} [concurrency=1] - Mount concurrency. `1` (default) = serial. Higher values mount in parallel batches.
16
+ */
17
+ /**
18
+ * @typedef {object} MountResult
19
+ * @property {string} packageName
20
+ * @property {string} mountPath - Dot-notation path used at the time of mount.
21
+ * @property {string} moduleID - moduleID returned by api.add().
22
+ * @property {DiscoverResult} discoverResult
23
+ * @property {{version: string, default: boolean}|null} versionConfig - Versioning descriptor when the module mounted under a `vMAJOR.<mountPath>` prefix (multi-version case from `#buildVersionConfigs`), otherwise `null`. `version` is the slothlet version tag (`vMAJOR`); `default` indicates whether this entry is the default for the unversioned dispatch path.
24
+ */
25
+ /**
26
+ * @typedef {object} FailureEntry
27
+ * @property {DiscoverResult|string} item - The cache entry or name that failed.
28
+ * @property {Error} error
29
+ */
30
+ /**
31
+ * Module discovery + mount handler.
32
+ * @class
33
+ * @extends ComponentBase
34
+ */
1
35
  export class ModuleManager extends ComponentBase {
36
+ /**
37
+ * Property name used by slothlet's auto-discovery initialization loop.
38
+ * @type {string}
39
+ * @static
40
+ */
2
41
  static slothletProperty: string;
3
- discover(options?: {}): Promise<Readonly<{
4
- packageName: any;
5
- packageRoot: any;
6
- mountPath: readonly any[];
7
- apiDir: any;
8
- manifest: any;
9
- }>[]>;
10
- sort(results: any, comparator: any): any[];
11
- getDiscoveryCache(): any[];
42
+ /**
43
+ * @param {object} slothlet - Parent slothlet instance.
44
+ */
45
+ constructor(slothlet: object);
46
+ /**
47
+ * Walk the filesystem for slothlet modules, validate manifests, dedupe, and
48
+ * replace the discovery cache with the new results. Returns the sorted
49
+ * candidate list using sortModules's default comparator.
50
+ *
51
+ * Emits `modules:discover-start` before the walk and
52
+ * `modules:discover-complete` after the cache is populated.
53
+ *
54
+ * @param {DiscoverOptions} [options]
55
+ * @returns {Promise<DiscoverResult[]>} Validated discovery results in walk order (apply `sortModules()` for deterministic ordering).
56
+ */
57
+ discover(options?: DiscoverOptions): Promise<DiscoverResult[]>;
58
+ /**
59
+ * Pure sort wrapper. Forwards to `sortModules()` without touching cache state.
60
+ *
61
+ * @param {DiscoverResult[]} results
62
+ * @param {(a: DiscoverResult, b: DiscoverResult) => number} [comparator]
63
+ * @returns {DiscoverResult[]}
64
+ */
65
+ sort(results: DiscoverResult[], comparator?: (a: DiscoverResult, b: DiscoverResult) => number): DiscoverResult[];
66
+ /**
67
+ * Return the list of modules currently in the discovery cache.
68
+ * @returns {DiscoverResult[]}
69
+ */
70
+ getDiscoveryCache(): DiscoverResult[];
71
+ /**
72
+ * Empty the discovery cache. Does not affect already-mounted modules.
73
+ * @returns {void}
74
+ */
12
75
  clearDiscoveryCache(): void;
13
- getStaleMounts(): any[];
14
- addModule(nameOrResult: any, options?: {}): Promise<{
15
- packageName: any;
16
- mountPath: any;
17
- moduleID: any;
18
- discoverResult: any;
19
- versionConfig: any;
76
+ /**
77
+ * Compute the stale-mount set per S3b: mounted modules that did not surface
78
+ * in the most recent `discover()` cache. Host calls this after re-discovery
79
+ * to decide what to unmount.
80
+ *
81
+ * @returns {MountResult[]} Mounts whose `${packageName}@${version}` is no longer in the cache.
82
+ */
83
+ getStaleMounts(): MountResult[];
84
+ /**
85
+ * Mount a single module — by name (cache lookup), by DiscoverResult directly,
86
+ * or with a lazy-trigger discover() if the name is not cached.
87
+ *
88
+ * @param {string|DiscoverResult} nameOrResult
89
+ * @param {AddModuleOptions} [options]
90
+ * @returns {Promise<MountResult>}
91
+ * @throws {SlothletError} `MODULE_PACKAGE_NOT_FOUND` when a name cannot be resolved.
92
+ * @throws {SlothletError} `MODULE_MOUNT_COLLISION` when the exact mountPath is already occupied and `collisionMode` is `"error"`.
93
+ */
94
+ addModule(nameOrResult: string | DiscoverResult, options?: AddModuleOptions): Promise<MountResult>;
95
+ /**
96
+ * Mount a list of modules.
97
+ *
98
+ * @param {Array<string|DiscoverResult>} items - Heterogeneous array; strings resolved through the discovery cache.
99
+ * @param {AddModulesOptions} [options]
100
+ * @returns {Promise<MountResult[] | {mounted: MountResult[], failed: FailureEntry[]}>} Plain array under `throw`/`rollback`; aggregate object under `best-effort`.
101
+ */
102
+ addModules(items: Array<string | DiscoverResult>, options?: AddModulesOptions): Promise<MountResult[] | {
103
+ mounted: MountResult[];
104
+ failed: FailureEntry[];
20
105
  }>;
21
- addModules(items: any, options?: {}): Promise<any[] | {
22
- mounted: any[];
23
- failed: any[];
24
- }>;
25
- removeModule(name: any, opts?: {}): Promise<boolean>;
106
+ /**
107
+ * Unmount a previously-mounted module by package name (and optional version
108
+ * when multi-version mounts are in play).
109
+ *
110
+ * @param {string} name - Package name.
111
+ * @param {object} [opts]
112
+ * @param {string} [opts.version] - Disambiguator when more than one mounted entry shares the name.
113
+ * @returns {Promise<boolean>} `true` when something was unmounted, `false` when no matching mount was found.
114
+ */
115
+ removeModule(name: string, opts?: {
116
+ version?: string | undefined;
117
+ }): Promise<boolean>;
26
118
  #private;
27
119
  }
120
+ export type DiscoverResult = import("../helpers/module-discovery.mjs").DiscoverResult;
121
+ export type DiscoverOptions = import("../helpers/module-discovery.mjs").DiscoverOptions;
122
+ export type AddModuleOptions = {
123
+ /**
124
+ * - Per-mount override; defaults to "merge" (matches `DEFAULT_MODULE_COLLISION_MODE`). Use "error" to throw on any pre-flight mountPath collision against api-manager's `addHistory`.
125
+ */
126
+ collisionMode?: "merge" | "replace" | "skip" | "warn" | "merge-replace" | "error" | undefined;
127
+ /**
128
+ * - When the discovery cache holds multiple versions of the same `name`, mount only the entry whose package.json version matches.
129
+ */
130
+ version?: string | undefined;
131
+ /**
132
+ * - Options to forward to the lazy discover() call if the cache is empty. Ignored when the cache already holds data.
133
+ */
134
+ discover?: import("../helpers/module-discovery.mjs").DiscoverOptions | undefined;
135
+ };
136
+ export type AddModulesOptions = {
137
+ /**
138
+ * - Per-call collision policy passed to every mount. Defaults to "merge" (matches `DEFAULT_MODULE_COLLISION_MODE`); use "error" to throw on any pre-flight mountPath collision.
139
+ */
140
+ collisionMode?: "merge" | "replace" | "skip" | "warn" | "merge-replace" | "error" | undefined;
141
+ /**
142
+ * - Failure policy. `throw` (default): throw on first failure, leave mounted entries in place. `rollback`: throw on first failure, remove every entry mounted in this call. `best-effort`: collect failures, return aggregate `{ mounted, failed }`.
143
+ */
144
+ onFailure?: "throw" | "rollback" | "best-effort" | undefined;
145
+ /**
146
+ * - Mount concurrency. `1` (default) = serial. Higher values mount in parallel batches.
147
+ */
148
+ concurrency?: number | undefined;
149
+ };
150
+ export type MountResult = {
151
+ packageName: string;
152
+ /**
153
+ * - Dot-notation path used at the time of mount.
154
+ */
155
+ mountPath: string;
156
+ /**
157
+ * - moduleID returned by api.add().
158
+ */
159
+ moduleID: string;
160
+ discoverResult: DiscoverResult;
161
+ /**
162
+ * - Versioning descriptor when the module mounted under a `vMAJOR.<mountPath>` prefix (multi-version case from `#buildVersionConfigs`), otherwise `null`. `version` is the slothlet version tag (`vMAJOR`); `default` indicates whether this entry is the default for the unversioned dispatch path.
163
+ */
164
+ versionConfig: {
165
+ version: string;
166
+ default: boolean;
167
+ } | null;
168
+ };
169
+ export type FailureEntry = {
170
+ /**
171
+ * - The cache entry or name that failed.
172
+ */
173
+ item: DiscoverResult | string;
174
+ error: Error;
175
+ };
28
176
  import { ComponentBase } from "#factories/component-base";