conduithub 0.0.3 → 1.0.0

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 (68) hide show
  1. package/dist/core/conduit-hub/index.cjs +188 -0
  2. package/dist/core/conduit-hub/index.d.cts +44 -0
  3. package/dist/core/conduit-hub/index.d.mts +44 -0
  4. package/dist/core/conduit-hub/index.d.ts +44 -0
  5. package/dist/core/conduit-hub/index.mjs +186 -0
  6. package/dist/core/config-manager/index.cjs +216 -0
  7. package/dist/core/config-manager/index.d.cts +7 -0
  8. package/dist/core/config-manager/index.d.mts +7 -0
  9. package/dist/core/config-manager/index.d.ts +7 -0
  10. package/dist/core/config-manager/index.mjs +214 -0
  11. package/dist/core/event-bus/index.cjs +154 -53
  12. package/dist/core/event-bus/index.d.cts +2 -42
  13. package/dist/core/event-bus/index.d.mts +2 -42
  14. package/dist/core/event-bus/index.d.ts +2 -42
  15. package/dist/core/event-bus/index.mjs +153 -52
  16. package/dist/core/hook/index.cjs +185 -148
  17. package/dist/core/hook/index.d.cts +28 -16
  18. package/dist/core/hook/index.d.mts +28 -16
  19. package/dist/core/hook/index.d.ts +28 -16
  20. package/dist/core/hook/index.mjs +183 -146
  21. package/dist/core/index.cjs +17 -1
  22. package/dist/core/index.d.cts +184 -3
  23. package/dist/core/index.d.mts +184 -3
  24. package/dist/core/index.d.ts +184 -3
  25. package/dist/core/index.mjs +12 -1
  26. package/dist/core/plugin/index.cjs +271 -0
  27. package/dist/core/plugin/index.d.cts +7 -0
  28. package/dist/core/plugin/index.d.mts +7 -0
  29. package/dist/core/plugin/index.d.ts +7 -0
  30. package/dist/core/plugin/index.mjs +268 -0
  31. package/dist/core/service-container/index.cjs +306 -0
  32. package/dist/core/service-container/index.d.cts +51 -0
  33. package/dist/core/service-container/index.d.mts +51 -0
  34. package/dist/core/service-container/index.d.ts +51 -0
  35. package/dist/core/service-container/index.mjs +304 -0
  36. package/dist/core/state-manager/index.cjs +195 -0
  37. package/dist/core/state-manager/index.d.cts +39 -0
  38. package/dist/core/state-manager/index.d.mts +39 -0
  39. package/dist/core/state-manager/index.d.ts +39 -0
  40. package/dist/core/state-manager/index.mjs +193 -0
  41. package/dist/index.cjs +34 -5
  42. package/dist/index.d.cts +54 -2
  43. package/dist/index.d.mts +54 -2
  44. package/dist/index.d.ts +54 -2
  45. package/dist/index.mjs +13 -1
  46. package/dist/shared/conduithub.BDwZXllF.mjs +63 -0
  47. package/dist/shared/{conduithub.CvMLTa-R.cjs → conduithub.BNQsddJO.cjs} +2 -9
  48. package/dist/shared/{conduithub.74V0wiLi.mjs → conduithub.BNefRQsK.mjs} +3 -9
  49. package/dist/shared/conduithub.BZQmkQy7.d.cts +52 -0
  50. package/dist/shared/conduithub.BqUYv04j.cjs +68 -0
  51. package/dist/shared/conduithub.Bq_7Xj0J.cjs +18 -0
  52. package/dist/shared/conduithub.BzLwccre.d.mts +52 -0
  53. package/dist/shared/conduithub.CkOQG3cD.mjs +14 -0
  54. package/dist/shared/conduithub.CmZo_Vuc.cjs +38 -0
  55. package/dist/shared/conduithub.DQO1dRnn.cjs +33 -0
  56. package/dist/shared/conduithub.DQOWQ-Bx.d.ts +52 -0
  57. package/dist/shared/conduithub.DsOOeNwU.cjs +269 -0
  58. package/dist/shared/conduithub.DyQQrHW9.mjs +267 -0
  59. package/dist/shared/conduithub.G7ICpZIy.mjs +36 -0
  60. package/dist/shared/conduithub.alPiaJax.mjs +29 -0
  61. package/dist/shared/conduithub.bsiNMTVD.mjs +59 -0
  62. package/dist/shared/conduithub.gF2DFc43.cjs +76 -0
  63. package/dist/utils/index.cjs +18 -5
  64. package/dist/utils/index.d.cts +33 -2
  65. package/dist/utils/index.d.mts +33 -2
  66. package/dist/utils/index.d.ts +33 -2
  67. package/dist/utils/index.mjs +7 -1
  68. package/package.json +52 -1
@@ -1,4 +1,9 @@
1
- import { c as createLogger, g as generateUuid } from '../../shared/conduithub.74V0wiLi.mjs';
1
+ import { C as ConduithubError } from '../../shared/conduithub.BDwZXllF.mjs';
2
+ import { c as createLogger } from '../../shared/conduithub.BNefRQsK.mjs';
3
+ import 'process';
4
+ import 'readline';
5
+ import { g as generateUuid } from '../../shared/conduithub.CkOQG3cD.mjs';
6
+ import { E as ERROR_CODE } from '../../shared/conduithub.G7ICpZIy.mjs';
2
7
  import 'uuid';
3
8
 
4
9
  class Hook {
@@ -7,80 +12,136 @@ class Hook {
7
12
  logger;
8
13
  failFast;
9
14
  onError;
15
+ maxHandlersPerHook;
16
+ defaultTimeoutMs;
17
+ lock = Promise.resolve();
10
18
  constructor(options, logger) {
11
19
  this.failFast = options?.failFast ?? false;
12
20
  this.onError = options?.onError;
21
+ this.maxHandlersPerHook = options?.maxHandlersPerHook ?? 100;
22
+ this.defaultTimeoutMs = options?.defaultTimeoutMs ?? 5e3;
13
23
  this.logger = logger ?? createLogger({ name: "Hook" });
14
24
  }
15
- ensure() {
16
- if (!this.initialized) throw new Error("Hook system is not initialized");
25
+ async withLock(operation) {
26
+ const currentLock = this.lock;
27
+ let resolveLock;
28
+ this.lock = new Promise((resolve) => {
29
+ resolveLock = resolve;
30
+ });
31
+ await currentLock;
32
+ try {
33
+ return await operation();
34
+ } finally {
35
+ resolveLock();
36
+ }
17
37
  }
18
- async initialize() {
38
+ ensureInitialized() {
19
39
  if (!this.initialized) {
40
+ throw new ConduithubError(ERROR_CODE.HOOK_SYSTEM_NOT_INITIALIZED);
41
+ }
42
+ }
43
+ sanitizeLog(data) {
44
+ if (typeof data === "string") {
45
+ return data.length > 100 ? `${data.substring(0, 100)}...` : data;
46
+ }
47
+ if (typeof data === "object" && data !== null) {
48
+ return "[Object]";
49
+ }
50
+ return String(data);
51
+ }
52
+ async initialize() {
53
+ return this.withLock(async () => {
54
+ if (this.initialized) return;
20
55
  this.initialized = true;
21
56
  this.logger.success("Hook system initialized successfully");
22
- }
57
+ });
23
58
  }
24
59
  async shutdown() {
25
- this.ensure();
26
- const hookCount = Array.from(this.hooks.values()).reduce(
60
+ return this.withLock(async () => {
61
+ this.ensureInitialized();
62
+ const hookCount = this.getTotalHandlerCount();
63
+ this.hooks.clear();
64
+ this.initialized = false;
65
+ this.logger.success(
66
+ `Hook system shutdown completed - cleared ${hookCount} handlers`
67
+ );
68
+ });
69
+ }
70
+ getTotalHandlerCount() {
71
+ return Array.from(this.hooks.values()).reduce(
27
72
  (total, handlers) => total + handlers.length,
28
73
  0
29
74
  );
30
- this.hooks.clear();
31
- this.initialized = false;
32
- this.logger.success(
33
- `Hook system shutdown completed - cleared ${hookCount} handlers`
34
- );
35
75
  }
36
- registerHook(hook, handler, priority = 0, customId) {
37
- this.ensure();
38
- if (!this.hooks.has(hook)) this.hooks.set(hook, []);
39
- const id = customId ?? generateUuid();
40
- const entry = {
41
- id,
42
- hook: String(hook),
43
- handler,
44
- priority
45
- };
46
- this.hooks.get(hook).push(entry);
47
- this.hooks.get(hook).sort((a, b) => b.priority - a.priority);
48
- const handlerCount = this.hooks.get(hook).length;
49
- this.logger.debug(
50
- `Hook registered: '${String(hook)}' \u2192 ${id} (priority: ${priority}, total handlers: ${handlerCount})`
51
- );
52
- return id;
76
+ async registerHook(hook, handler, priority = 0, customId) {
77
+ return this.withLock(async () => {
78
+ this.ensureInitialized();
79
+ if (!this.hooks.has(hook)) this.hooks.set(hook, []);
80
+ const handlers = this.hooks.get(hook);
81
+ if (handlers.length >= this.maxHandlersPerHook) {
82
+ throw new ConduithubError(
83
+ `${ERROR_CODE.HOOK_HANDLER_LIMIT_EXCEEDED} ${String(hook)} (${this.maxHandlersPerHook})`
84
+ );
85
+ }
86
+ const id = customId ?? generateUuid();
87
+ if (customId && handlers.some((h) => h.id === customId)) {
88
+ throw new ConduithubError(
89
+ `${ERROR_CODE.DUPLICATE_HOOK_HANDLER_ID} ${String(hook)}: ${customId}`
90
+ );
91
+ }
92
+ const entry = {
93
+ id,
94
+ hook: String(hook),
95
+ handler,
96
+ priority
97
+ };
98
+ handlers.push(entry);
99
+ this.logger.debug(
100
+ `Hook registered: '${String(hook)}' \u2192 ${id} (priority: ${priority}, total handlers: ${handlers.length})`
101
+ );
102
+ return id;
103
+ });
53
104
  }
54
- unregisterHook(hook, id) {
55
- this.ensure();
56
- const list = this.hooks.get(hook);
57
- if (!list) {
105
+ async unregisterHook(hook, id) {
106
+ return this.withLock(async () => {
107
+ this.ensureInitialized();
108
+ const list = this.hooks.get(hook);
109
+ if (!list) {
110
+ this.logger.warn(
111
+ `Failed to unregister hook: '${String(hook)}' \u2192 ${id} (hook not found)`
112
+ );
113
+ return false;
114
+ }
115
+ const index = list.findIndex((h) => h.id === id);
116
+ if (index >= 0) {
117
+ list.splice(index, 1);
118
+ const remainingCount = list.length;
119
+ if (remainingCount === 0) this.hooks.delete(hook);
120
+ this.logger.debug(
121
+ `Hook unregistered: '${String(hook)}' \u2192 ${id} (remaining handlers: ${remainingCount})`
122
+ );
123
+ return true;
124
+ }
58
125
  this.logger.warn(
59
126
  `Failed to unregister hook: '${String(hook)}' \u2192 ${id} (handler not found)`
60
127
  );
61
128
  return false;
62
- }
63
- const index = list.findIndex((h) => h.id === id);
64
- if (index >= 0) {
65
- list.splice(index, 1);
66
- const remainingCount = list.length;
67
- if (remainingCount === 0) this.hooks.delete(hook);
68
- this.logger.debug(
69
- `Hook unregistered: '${String(hook)}' \u2192 ${id} (remaining handlers: ${remainingCount})`
70
- );
71
- return true;
72
- }
73
- this.logger.warn(
74
- `Failed to unregister hook: '${String(hook)}' \u2192 ${id} (handler not found)`
75
- );
76
- return false;
129
+ });
77
130
  }
78
- async handleHookResult(raw, failFast, hook, handlerId) {
131
+ async handleHookResult(raw, failFast, hook, handlerId, timeoutMs = this.defaultTimeoutMs) {
79
132
  try {
80
- const result = await raw;
133
+ const result = await Promise.race([
134
+ Promise.resolve(raw),
135
+ new Promise(
136
+ (_, reject) => setTimeout(() => reject(new Error("Handler timeout")), timeoutMs)
137
+ )
138
+ ]);
81
139
  if (typeof result === "object" && result && "success" in result) {
82
140
  const res = result;
83
- if (!res.success && failFast) throw new Error(res.error);
141
+ if (!res.success && failFast)
142
+ throw new ConduithubError(
143
+ res.error ?? ERROR_CODE.HOOK_EXECUTION_FAILED
144
+ );
84
145
  this.logger.debug(
85
146
  `Hook handler completed: '${String(hook)}' \u2192 ${handlerId} (success: ${res.success})`
86
147
  );
@@ -94,114 +155,90 @@ class Hook {
94
155
  if (failFast) throw err;
95
156
  const errorMessage = err instanceof Error ? err.message : String(err);
96
157
  this.logger.error(
97
- `Hook handler failed: '${String(hook)}' \u2192 ${handlerId} - ${errorMessage}`
158
+ `Hook handler failed: '${String(hook)}' \u2192 ${handlerId} - ${this.sanitizeLog(errorMessage)}`
98
159
  );
99
160
  this.onError?.(err, hook);
100
- return {
101
- success: false,
102
- error: errorMessage
103
- };
161
+ return { success: false, error: errorMessage };
104
162
  }
105
163
  }
106
- async executeHook(hook, data) {
107
- this.ensure();
108
- const list = this.hooks.get(hook);
109
- if (!list?.length) {
164
+ async executeHook(hook, data, context) {
165
+ return this.withLock(async () => {
166
+ this.ensureInitialized();
167
+ const list = this.hooks.get(hook);
168
+ if (!list?.length) {
169
+ this.logger.debug(
170
+ `Hook execution skipped: '${String(hook)}' (no handlers registered)`
171
+ );
172
+ return data;
173
+ }
174
+ list.sort((a, b) => b.priority - a.priority);
110
175
  this.logger.debug(
111
- `Hook execution skipped: '${String(hook)}' (no handlers registered)`
112
- );
113
- return data;
114
- }
115
- this.logger.debug(
116
- `Hook execution started: '${String(hook)}' (${list.length} handlers)`
117
- );
118
- let result = data;
119
- let successCount = 0;
120
- let errorCount = 0;
121
- for (const { handler, id } of list) {
122
- const {
123
- success,
124
- data: output,
125
- error
126
- } = await this.handleHookResult(
127
- Promise.resolve().then(() => handler(result)),
128
- this.failFast,
129
- hook,
130
- id
176
+ `Hook execution started: '${String(hook)}' (${list.length} handlers)`
131
177
  );
132
- if (success) {
133
- successCount++;
134
- if (output !== void 0) result = output;
135
- } else {
136
- errorCount++;
137
- if (this.failFast) throw new Error(error);
178
+ let result = data;
179
+ let successCount = 0;
180
+ let errorCount = 0;
181
+ for (const { handler, id } of list) {
182
+ const {
183
+ success,
184
+ data: output,
185
+ error
186
+ } = await this.handleHookResult(
187
+ Promise.resolve().then(() => handler(result, context)),
188
+ this.failFast,
189
+ hook,
190
+ id
191
+ );
192
+ if (success) {
193
+ successCount++;
194
+ if (output !== void 0) result = output;
195
+ } else {
196
+ errorCount++;
197
+ if (this.failFast)
198
+ throw new ConduithubError(error ?? ERROR_CODE.UNKNOWN_ERROR);
199
+ }
138
200
  }
139
- }
140
- this.logger.debug(
141
- `Hook execution completed: '${String(hook)}' (${successCount} succeeded, ${errorCount} failed)`
142
- );
143
- return result;
144
- }
145
- async executeHookSeries(hook, data) {
146
- this.ensure();
147
- const list = this.hooks.get(hook);
148
- if (!list?.length) {
149
201
  this.logger.debug(
150
- `Hook series execution skipped: '${String(hook)}' (no handlers registered)`
151
- );
152
- return [];
153
- }
154
- this.logger.debug(
155
- `Hook series execution started: '${String(hook)}' (${list.length} handlers)`
156
- );
157
- const results = [];
158
- for (const { handler, id } of list) {
159
- const result = await this.handleHookResult(
160
- Promise.resolve().then(() => handler(data)),
161
- false,
162
- // Never fail fast in series execution, just collect results
163
- hook,
164
- id
202
+ `Hook execution completed: '${String(hook)}' (${successCount} succeeded, ${errorCount} failed)`
165
203
  );
166
- results.push(result);
167
- if (!result.success && this.failFast) break;
168
- }
169
- const successCount = results.filter((r) => r.success).length;
170
- const errorCount = results.filter((r) => !r.success).length;
171
- this.logger.debug(
172
- `Hook series execution completed: '${String(hook)}' (${successCount} succeeded, ${errorCount} failed)`
173
- );
174
- return results;
204
+ return result;
205
+ });
175
206
  }
176
- async executeHookSeriesWithContext(hook, data, context) {
177
- this.ensure();
178
- const handlers = this.hooks.get(hook);
179
- if (!handlers || handlers.length === 0) {
207
+ async executeHookSeries(hook, data, context) {
208
+ return this.withLock(async () => {
209
+ this.ensureInitialized();
210
+ const list = this.hooks.get(hook);
211
+ if (!list?.length) {
212
+ this.logger.debug(
213
+ `Hook series execution skipped: '${String(hook)}' (no handlers registered)`
214
+ );
215
+ return [];
216
+ }
217
+ list.sort((a, b) => b.priority - a.priority);
180
218
  this.logger.debug(
181
- `Hook series execution skipped: '${String(hook)}' (no handlers registered)`
219
+ `Hook series execution started: '${String(hook)}' (${list.length} handlers)`
182
220
  );
183
- return [];
184
- }
185
- this.logger.debug(
186
- `Hook series execution started: '${String(hook)}' (${handlers.length} handlers)`
187
- );
188
- const results = [];
189
- for (const { handler, id } of handlers) {
190
- const result = await this.handleHookResult(
191
- Promise.resolve().then(() => handler(data)),
192
- this.failFast,
193
- hook,
194
- id
221
+ const results = [];
222
+ for (const { handler, id } of list) {
223
+ const result = await this.handleHookResult(
224
+ Promise.resolve().then(() => handler(data, context)),
225
+ false,
226
+ hook,
227
+ id
228
+ );
229
+ results.push(result);
230
+ if (!result.success && this.failFast) break;
231
+ }
232
+ const successCount = results.filter((r) => r.success).length;
233
+ const errorCount = results.length - successCount;
234
+ this.logger.debug(
235
+ `Hook series execution completed: '${String(hook)}' (${successCount} succeeded, ${errorCount} failed)`
195
236
  );
196
- results.push(result);
197
- if (!result.success && this.failFast) break;
198
- }
199
- const successCount = results.filter((r) => r.success).length;
200
- const errorCount = results.filter((r) => !r.success).length;
201
- this.logger.debug(
202
- `Hook series execution completed: '${String(hook)}' (${successCount} succeeded, ${errorCount} failed)`
203
- );
204
- return results;
237
+ return results;
238
+ });
239
+ }
240
+ async executeHookSeriesWithContext(hook, data, context) {
241
+ return this.executeHookSeries(hook, data, context);
205
242
  }
206
243
  }
207
244
 
@@ -1,11 +1,27 @@
1
1
  'use strict';
2
2
 
3
+ const core_configManager_index = require('./config-manager/index.cjs');
3
4
  const core_eventBus_index = require('./event-bus/index.cjs');
4
5
  const core_hook_index = require('./hook/index.cjs');
5
- require('../shared/conduithub.CvMLTa-R.cjs');
6
+ const core_plugin_index = require('./plugin/index.cjs');
7
+ const core_serviceContainer_index = require('./service-container/index.cjs');
8
+ const core_stateManager_index = require('./state-manager/index.cjs');
9
+ const manager = require('../shared/conduithub.DsOOeNwU.cjs');
10
+ require('../shared/conduithub.CmZo_Vuc.cjs');
11
+ require('../shared/conduithub.DQO1dRnn.cjs');
12
+ require('../shared/conduithub.BNQsddJO.cjs');
13
+ require('process');
14
+ require('readline');
6
15
  require('uuid');
16
+ require('../shared/conduithub.BqUYv04j.cjs');
17
+ require('../shared/conduithub.Bq_7Xj0J.cjs');
7
18
 
8
19
 
9
20
 
21
+ exports.ConfigManager = core_configManager_index.ConfigManager;
10
22
  exports.EventBus = core_eventBus_index.EventBus;
11
23
  exports.Hook = core_hook_index.Hook;
24
+ exports.BasePlugin = core_plugin_index.BasePlugin;
25
+ exports.ServiceContainer = core_serviceContainer_index.ServiceContainer;
26
+ exports.StateManager = core_stateManager_index.StateManager;
27
+ exports.PluginManager = manager.PluginManager;
@@ -1,3 +1,184 @@
1
- export { EventBus, EventData, EventHandlerRecord } from './event-bus/index.cjs';
2
- export { Hook, HookHandler, HookResult } from './hook/index.cjs';
3
- import '../shared/conduithub.B7aryjPG.cjs';
1
+ import { z } from 'zod';
2
+ import { Hook, HookResult } from './hook/index.cjs';
3
+ export { HookHandler } from './hook/index.cjs';
4
+ import { a as Logger } from '../shared/conduithub.B7aryjPG.cjs';
5
+ import { E as EventBus, a as EventData } from '../shared/conduithub.BZQmkQy7.cjs';
6
+ import { ServiceContainer } from './service-container/index.cjs';
7
+ export { ServiceDescriptor } from './service-container/index.cjs';
8
+ import { StateManager } from './state-manager/index.cjs';
9
+ export { StateChangeHandler } from './state-manager/index.cjs';
10
+
11
+ interface PluginStatus {
12
+ name: string;
13
+ version: string;
14
+ status: "registered" | "initialized" | "running" | "stopped" | "destroyed" | "error";
15
+ config: PluginConfig;
16
+ error?: string;
17
+ lastActivity: number;
18
+ }
19
+ declare class PluginManager {
20
+ private eventBus;
21
+ private logger;
22
+ private serviceContainer;
23
+ private stateManager;
24
+ private hookSystem;
25
+ private configManager;
26
+ private plugins;
27
+ private pluginStatuses;
28
+ private pluginConfigs;
29
+ constructor(eventBus: EventBus<Record<string, unknown>>, logger: Logger, serviceContainer: ServiceContainer, stateManager: StateManager, hookSystem: Hook<Record<string, {
30
+ input: unknown;
31
+ output: unknown;
32
+ }>>, configManager: ConfigManager);
33
+ private log;
34
+ registerPlugin(plugin: BasePlugin, config?: PluginConfig): Promise<void>;
35
+ unregisterPlugin(pluginName: string): Promise<void>;
36
+ initializePlugin(pluginName: string): Promise<void>;
37
+ startPlugin(pluginName: string): Promise<void>;
38
+ stopPlugin(pluginName: string): Promise<void>;
39
+ shutdownAll(): Promise<void>;
40
+ isPluginRegistered(pluginName: string): boolean;
41
+ isPluginRunning(pluginName: string): boolean;
42
+ getPluginStatus(pluginName: string): PluginStatus | undefined;
43
+ listPlugins(): string[];
44
+ getAllPluginStatuses(): PluginStatus[];
45
+ getPlugin(pluginName: string): BasePlugin | undefined;
46
+ getPluginConfig(pluginName: string): PluginConfig | undefined;
47
+ updatePluginConfig(pluginName: string, config: Partial<PluginConfig>): Promise<void>;
48
+ }
49
+
50
+ interface PluginConfig {
51
+ name: string;
52
+ version: string;
53
+ enabled: boolean;
54
+ dependencies?: string[];
55
+ config?: Record<string, unknown>;
56
+ }
57
+ interface PluginContext<EM extends Record<string, unknown> = Record<string, unknown>, HM extends Record<string, {
58
+ input: unknown;
59
+ output: unknown;
60
+ }> = Record<string, {
61
+ input: unknown;
62
+ output: unknown;
63
+ }>> {
64
+ eventBus: EventBus<EM>;
65
+ logger: Logger;
66
+ config: PluginConfig;
67
+ serviceContainer: ServiceContainer;
68
+ hookSystem: Hook<HM>;
69
+ stateManager: StateManager;
70
+ }
71
+ interface PluginMetadata {
72
+ name: string;
73
+ version: string;
74
+ description?: string;
75
+ author?: string;
76
+ dependencies?: string[];
77
+ hooks: string[];
78
+ events: string[];
79
+ }
80
+ type PluginLifecycle = "beforeInit" | "afterInit" | "beforeStart" | "afterStart" | "beforeStop" | "afterStop" | "beforeDestroy" | "afterDestroy";
81
+ declare abstract class BasePlugin<T extends Record<string, unknown> = Record<string, unknown>, EM extends Record<string, unknown> = Record<string, unknown>, HM extends Record<string, {
82
+ input: unknown;
83
+ output: unknown;
84
+ }> = Record<string, {
85
+ input: unknown;
86
+ output: unknown;
87
+ }>> {
88
+ protected config: PluginConfig & {
89
+ config: T;
90
+ };
91
+ protected context: PluginContext<EM, HM>;
92
+ protected metadata: PluginMetadata;
93
+ protected isInitialized: boolean;
94
+ protected isRunning: boolean;
95
+ private managedEventHandlers;
96
+ private managedHookHandlers;
97
+ private lock;
98
+ constructor(config: PluginConfig & {
99
+ config: T;
100
+ });
101
+ abstract getMetadata(): PluginMetadata;
102
+ initialize(context: PluginContext<EM, HM>): Promise<void>;
103
+ start(): Promise<void>;
104
+ stop(): Promise<void>;
105
+ destroy(): Promise<void>;
106
+ protected abstract onInitialize(): Promise<void>;
107
+ protected abstract onStart(): Promise<void>;
108
+ protected abstract onStop(): Promise<void>;
109
+ protected abstract onDestroy(): Promise<void>;
110
+ private executeLifecycleHook;
111
+ getConfig(): PluginConfig & {
112
+ config: T;
113
+ };
114
+ getContext(): PluginContext<EM, HM>;
115
+ isPluginInitialized(): boolean;
116
+ isPluginRunning(): boolean;
117
+ protected emit<K extends keyof EM>(event: K, data: EM[K]): Promise<void>;
118
+ protected on<K extends keyof EM>(event: K, listener: (payload: EM[K], event: EventData<K & string, EM[K]>) => Promise<void> | void): string;
119
+ protected once<K extends keyof EM>(event: K, listener: (payload: EM[K], event: EventData<K & string, EM[K]>) => Promise<void> | void): string;
120
+ protected onManaged<K extends keyof EM>(event: K, listener: (payload: EM[K], event: EventData<K & string, EM[K]>) => Promise<void> | void): string;
121
+ protected onceManaged<K extends keyof EM>(event: K, listener: (payload: EM[K], event: EventData<K & string, EM[K]>) => Promise<void> | void): string;
122
+ protected off<K extends keyof EM>(event: K, handlerId: string): void;
123
+ protected executeHook<K extends keyof HM>(hook: K, input: HM[K]["input"]): Promise<HM[K]["output"]>;
124
+ protected executeHookSeries<K extends keyof HM>(hook: K, input: HM[K]["input"]): Promise<HookResult<HM[K]["output"]>[]>;
125
+ protected executeHookSeriesWithContext<K extends keyof HM>(hook: K, input: HM[K]["input"], context: Record<string, unknown>): Promise<HookResult<HM[K]["output"]>[]>;
126
+ protected registerHook<K extends keyof HM>(hook: K, handler: (data: HM[K]["input"], context?: Record<string, unknown>) => HM[K]["output"] | Promise<HM[K]["output"]> | HookResult<HM[K]["output"]> | Promise<HookResult<HM[K]["output"]>>, priority?: number, customId?: string): Promise<string>;
127
+ protected registerHookManaged<K extends keyof HM>(hook: K, handler: (data: HM[K]["input"], context?: Record<string, unknown>) => HM[K]["output"] | Promise<HM[K]["output"]> | HookResult<HM[K]["output"]> | Promise<HookResult<HM[K]["output"]>>, priority?: number, customId?: string): Promise<string>;
128
+ protected unregisterHook<K extends keyof HM>(hook: K, handlerId: string): Promise<boolean>;
129
+ protected getStatus(): {
130
+ initialized: boolean;
131
+ running: boolean;
132
+ };
133
+ protected getName(): string;
134
+ protected getVersion(): string;
135
+ protected isEnabled(): boolean;
136
+ protected getState(key: string): unknown;
137
+ protected setState(key: string, value: unknown): void;
138
+ protected deleteState(key: string): void;
139
+ protected get logger(): Logger;
140
+ updateConfig(update: Partial<PluginConfig & {
141
+ config: T;
142
+ }>): void;
143
+ private cleanupManagedHandlers;
144
+ private cleanupManagedHooks;
145
+ private withLock;
146
+ }
147
+
148
+ declare class ConfigManager {
149
+ private config;
150
+ private pluginConfigs;
151
+ private isInitialized;
152
+ initialize(config: Record<string, unknown>): Promise<void>;
153
+ shutdown(): Promise<void>;
154
+ get<T>(key: string, defaultValue?: T): T | undefined;
155
+ set<T>(key: string, value: T): void;
156
+ has(key: string): boolean;
157
+ delete(key: string): boolean;
158
+ loadConfig(config: Record<string, unknown>): void;
159
+ clearConfig(): void;
160
+ getPluginConfig(pluginName: string): PluginConfig | undefined;
161
+ setPluginConfig(pluginName: string, config: PluginConfig): void;
162
+ updatePluginConfig(pluginName: string, updates: Partial<PluginConfig>): void;
163
+ hasPluginConfig(pluginName: string): boolean;
164
+ deletePluginConfig(pluginName: string): boolean;
165
+ getAllPluginConfigs(): Record<string, PluginConfig>;
166
+ loadPluginConfigs(configs: Record<string, PluginConfig>): void;
167
+ validateConfig(schema: z.ZodTypeAny, config: unknown): {
168
+ valid: boolean;
169
+ errors: string[];
170
+ };
171
+ exportConfig(format?: "json"): string;
172
+ importConfig(configJson: string): void;
173
+ getPluginConfigNames(): string[];
174
+ getStats(): {
175
+ totalConfigKeys: number;
176
+ totalPluginConfigs: number;
177
+ configKeys: string[];
178
+ pluginConfigNames: string[];
179
+ };
180
+ watchConfig(key: string, callback: (value: unknown) => void): () => void;
181
+ }
182
+
183
+ export { BasePlugin, ConfigManager, EventBus, Hook, HookResult, PluginManager, ServiceContainer, StateManager };
184
+ export type { PluginConfig, PluginContext, PluginLifecycle, PluginMetadata, PluginStatus };