@shin1ohno/sage 0.10.0 → 0.11.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.
- package/dist/cli/mcp-handler.d.ts.map +1 -1
- package/dist/cli/mcp-handler.js +213 -6
- package/dist/cli/mcp-handler.js.map +1 -1
- package/dist/cli/signal-handler.d.ts +23 -0
- package/dist/cli/signal-handler.d.ts.map +1 -0
- package/dist/cli/signal-handler.js +51 -0
- package/dist/cli/signal-handler.js.map +1 -0
- package/dist/config/config-differ.d.ts +21 -0
- package/dist/config/config-differ.d.ts.map +1 -0
- package/dist/config/config-differ.js +194 -0
- package/dist/config/config-differ.js.map +1 -0
- package/dist/config/config-reload-service.d.ts +84 -0
- package/dist/config/config-reload-service.d.ts.map +1 -0
- package/dist/config/config-reload-service.js +234 -0
- package/dist/config/config-reload-service.js.map +1 -0
- package/dist/config/config-watcher.d.ts +78 -0
- package/dist/config/config-watcher.d.ts.map +1 -0
- package/dist/config/config-watcher.js +244 -0
- package/dist/config/config-watcher.js.map +1 -0
- package/dist/config/hot-reload-config.d.ts +16 -0
- package/dist/config/hot-reload-config.d.ts.map +1 -0
- package/dist/config/hot-reload-config.js +61 -0
- package/dist/config/hot-reload-config.js.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -1
- package/dist/services/reloadable/calendar-source-manager-adapter.d.ts +45 -0
- package/dist/services/reloadable/calendar-source-manager-adapter.d.ts.map +1 -0
- package/dist/services/reloadable/calendar-source-manager-adapter.js +106 -0
- package/dist/services/reloadable/calendar-source-manager-adapter.js.map +1 -0
- package/dist/services/reloadable/index.d.ts +46 -0
- package/dist/services/reloadable/index.d.ts.map +1 -0
- package/dist/services/reloadable/index.js +88 -0
- package/dist/services/reloadable/index.js.map +1 -0
- package/dist/services/reloadable/notion-service-adapter.d.ts +45 -0
- package/dist/services/reloadable/notion-service-adapter.d.ts.map +1 -0
- package/dist/services/reloadable/notion-service-adapter.js +86 -0
- package/dist/services/reloadable/notion-service-adapter.js.map +1 -0
- package/dist/services/reloadable/priority-engine-adapter.d.ts +73 -0
- package/dist/services/reloadable/priority-engine-adapter.d.ts.map +1 -0
- package/dist/services/reloadable/priority-engine-adapter.js +105 -0
- package/dist/services/reloadable/priority-engine-adapter.js.map +1 -0
- package/dist/services/reloadable/reminder-manager-adapter.d.ts +45 -0
- package/dist/services/reloadable/reminder-manager-adapter.d.ts.map +1 -0
- package/dist/services/reloadable/reminder-manager-adapter.js +80 -0
- package/dist/services/reloadable/reminder-manager-adapter.js.map +1 -0
- package/dist/services/reloadable/todo-list-manager-adapter.d.ts +45 -0
- package/dist/services/reloadable/todo-list-manager-adapter.d.ts.map +1 -0
- package/dist/services/reloadable/todo-list-manager-adapter.js +80 -0
- package/dist/services/reloadable/todo-list-manager-adapter.js.map +1 -0
- package/dist/services/reloadable/working-cadence-adapter.d.ts +52 -0
- package/dist/services/reloadable/working-cadence-adapter.d.ts.map +1 -0
- package/dist/services/reloadable/working-cadence-adapter.js +77 -0
- package/dist/services/reloadable/working-cadence-adapter.js.map +1 -0
- package/dist/services/service-registry.d.ts +85 -0
- package/dist/services/service-registry.d.ts.map +1 -0
- package/dist/services/service-registry.js +166 -0
- package/dist/services/service-registry.js.map +1 -0
- package/dist/tools/config/index.d.ts +9 -0
- package/dist/tools/config/index.d.ts.map +1 -0
- package/dist/tools/config/index.js +8 -0
- package/dist/tools/config/index.js.map +1 -0
- package/dist/tools/config/reload-handler.d.ts +35 -0
- package/dist/tools/config/reload-handler.d.ts.map +1 -0
- package/dist/tools/config/reload-handler.js +63 -0
- package/dist/tools/config/reload-handler.js.map +1 -0
- package/dist/tools/integrations/handlers.d.ts +2 -0
- package/dist/tools/integrations/handlers.d.ts.map +1 -1
- package/dist/tools/integrations/handlers.js.map +1 -1
- package/dist/tools/setup/handlers.d.ts +2 -0
- package/dist/tools/setup/handlers.d.ts.map +1 -1
- package/dist/tools/setup/handlers.js +14 -0
- package/dist/tools/setup/handlers.js.map +1 -1
- package/dist/types/hot-reload.d.ts +131 -0
- package/dist/types/hot-reload.d.ts.map +1 -0
- package/dist/types/hot-reload.js +5 -0
- package/dist/types/hot-reload.js.map +1 -0
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reloadable Service Adapter for CalendarSourceManager
|
|
3
|
+
*
|
|
4
|
+
* Wraps CalendarSourceManager to support hot-reload functionality.
|
|
5
|
+
* Reinitializes the service when calendar or integrations config changes.
|
|
6
|
+
*/
|
|
7
|
+
import { CalendarSourceManager } from '../../integrations/calendar-source-manager.js';
|
|
8
|
+
import { CalendarService } from '../../integrations/calendar-service.js';
|
|
9
|
+
import { GoogleCalendarService } from '../../integrations/google-calendar-service.js';
|
|
10
|
+
import { GoogleOAuthHandler } from '../../oauth/google-oauth-handler.js';
|
|
11
|
+
import { createLogger } from '../../utils/logger.js';
|
|
12
|
+
const logger = createLogger('CalendarSourceManagerAdapter');
|
|
13
|
+
/**
|
|
14
|
+
* Create GoogleCalendarService if Google Calendar integration is enabled and configured
|
|
15
|
+
*/
|
|
16
|
+
function createGoogleCalendarServiceIfEnabled(config) {
|
|
17
|
+
// Check if Google Calendar is enabled via integrations config
|
|
18
|
+
if (!config.integrations.googleCalendar.enabled) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
// Get OAuth credentials from environment variables
|
|
22
|
+
const clientId = process.env.GOOGLE_CLIENT_ID;
|
|
23
|
+
const clientSecret = process.env.GOOGLE_CLIENT_SECRET;
|
|
24
|
+
if (!clientId || !clientSecret) {
|
|
25
|
+
logger.warn('Google OAuth credentials not configured (GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET)');
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const oauthConfig = {
|
|
29
|
+
clientId,
|
|
30
|
+
clientSecret,
|
|
31
|
+
redirectUri: process.env.GOOGLE_REDIRECT_URI || 'http://localhost:3000/oauth/callback',
|
|
32
|
+
};
|
|
33
|
+
try {
|
|
34
|
+
const oauthHandler = new GoogleOAuthHandler(oauthConfig);
|
|
35
|
+
return new GoogleCalendarService(oauthHandler);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
logger.warn({ err: error }, 'Failed to create GoogleCalendarService - OAuth not configured');
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Default factory that creates CalendarSourceManager with CalendarService and GoogleCalendarService
|
|
44
|
+
*/
|
|
45
|
+
export function createCalendarSourceManager(config) {
|
|
46
|
+
const calendarService = new CalendarService();
|
|
47
|
+
const googleCalendarService = createGoogleCalendarServiceIfEnabled(config);
|
|
48
|
+
return new CalendarSourceManager({
|
|
49
|
+
calendarService,
|
|
50
|
+
googleCalendarService,
|
|
51
|
+
config,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Reloadable adapter for CalendarSourceManager
|
|
56
|
+
*/
|
|
57
|
+
export class CalendarSourceManagerAdapter {
|
|
58
|
+
name = 'CalendarSourceManager';
|
|
59
|
+
dependsOnSections = ['integrations', 'calendar'];
|
|
60
|
+
instance = null;
|
|
61
|
+
factory;
|
|
62
|
+
/**
|
|
63
|
+
* Constructor
|
|
64
|
+
* @param factoryOrInstance - Either a factory function or an existing instance
|
|
65
|
+
*/
|
|
66
|
+
constructor(factoryOrInstance) {
|
|
67
|
+
if (typeof factoryOrInstance === 'function') {
|
|
68
|
+
this.factory = factoryOrInstance;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.instance = factoryOrInstance;
|
|
72
|
+
this.factory = createCalendarSourceManager;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get the current CalendarSourceManager instance
|
|
77
|
+
*/
|
|
78
|
+
getInstance() {
|
|
79
|
+
return this.instance;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Shutdown the current instance
|
|
83
|
+
* CalendarSourceManager does not have explicit cleanup needs
|
|
84
|
+
*/
|
|
85
|
+
async shutdown() {
|
|
86
|
+
logger.debug('Shutting down CalendarSourceManager');
|
|
87
|
+
// CalendarSourceManager has no explicit cleanup
|
|
88
|
+
// Just clear the reference
|
|
89
|
+
this.instance = null;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Reinitialize with new configuration
|
|
93
|
+
*/
|
|
94
|
+
async reinitialize(config) {
|
|
95
|
+
logger.info('Reinitializing CalendarSourceManager with new config');
|
|
96
|
+
try {
|
|
97
|
+
this.instance = this.factory(config);
|
|
98
|
+
logger.info('CalendarSourceManager reinitialized successfully');
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
logger.error({ err: error }, 'Failed to reinitialize CalendarSourceManager');
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=calendar-source-manager-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-source-manager-adapter.js","sourceRoot":"","sources":["../../../src/services/reloadable/calendar-source-manager-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,MAAM,GAAG,YAAY,CAAC,8BAA8B,CAAC,CAAC;AAO5D;;GAEG;AACH,SAAS,oCAAoC,CAAC,MAAkB;IAC9D,8DAA8D;IAC9D,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,OA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AY,iBAAuE;QACjF,IAAI,OAAO,iBAAiB,KAAK,UAAU,EAAE,CAAC;YAC5C,IAAI,CAAC,OAAO,GAAG,iBAAiB,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,iBAAiB,CAAC;YAClC,IAAI,CAAC,OAAO,GAAG,2BAA2B,CAAC;QAC7C,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ;QACZ,MAAM,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACpD,gDAAgD;QAChD,2BAA2B;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,MAAkB;QACnC,MAAM,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;QAEpE,IAAI,CAAC;YACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrC,MAAM,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;QAClE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,8CAA8C,CAAC,CAAC;YAC7E,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reloadable Service Adapters
|
|
3
|
+
*
|
|
4
|
+
* Barrel export for all reloadable service adapters and factory function.
|
|
5
|
+
*/
|
|
6
|
+
export { CalendarSourceManagerAdapter, CalendarSourceManagerFactory, createCalendarSourceManager, } from './calendar-source-manager-adapter.js';
|
|
7
|
+
export { ReminderManagerAdapter, ReminderManagerFactory, createReminderManager, } from './reminder-manager-adapter.js';
|
|
8
|
+
export { WorkingCadenceAdapter, WorkingCadenceServiceFactory, createWorkingCadenceService, } from './working-cadence-adapter.js';
|
|
9
|
+
export { NotionServiceAdapter, NotionMCPServiceFactory, createNotionMCPService, } from './notion-service-adapter.js';
|
|
10
|
+
export { TodoListManagerAdapter, TodoListManagerFactory, createTodoListManager, } from './todo-list-manager-adapter.js';
|
|
11
|
+
export { PriorityEngineAdapter, PriorityEngineWrapper, PriorityEngineFactory, createPriorityEngine, } from './priority-engine-adapter.js';
|
|
12
|
+
import type { ReloadableService } from '../../types/hot-reload.js';
|
|
13
|
+
import type { UserConfig } from '../../types/config.js';
|
|
14
|
+
import { CalendarSourceManagerAdapter } from './calendar-source-manager-adapter.js';
|
|
15
|
+
import { ReminderManagerAdapter } from './reminder-manager-adapter.js';
|
|
16
|
+
import { WorkingCadenceAdapter } from './working-cadence-adapter.js';
|
|
17
|
+
import { NotionServiceAdapter } from './notion-service-adapter.js';
|
|
18
|
+
import { TodoListManagerAdapter } from './todo-list-manager-adapter.js';
|
|
19
|
+
import { PriorityEngineAdapter } from './priority-engine-adapter.js';
|
|
20
|
+
/**
|
|
21
|
+
* Service instances holder for factory function
|
|
22
|
+
*/
|
|
23
|
+
export interface ServiceInstances {
|
|
24
|
+
calendarSourceManager?: CalendarSourceManagerAdapter;
|
|
25
|
+
reminderManager?: ReminderManagerAdapter;
|
|
26
|
+
workingCadence?: WorkingCadenceAdapter;
|
|
27
|
+
notionService?: NotionServiceAdapter;
|
|
28
|
+
todoListManager?: TodoListManagerAdapter;
|
|
29
|
+
priorityEngine?: PriorityEngineAdapter;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create all reloadable service adapters
|
|
33
|
+
*
|
|
34
|
+
* Factory function that creates all service adapters with their default factories.
|
|
35
|
+
* Optionally accepts existing service instances to wrap.
|
|
36
|
+
*
|
|
37
|
+
* @param config - User configuration to initialize services with
|
|
38
|
+
* @param existingServices - Optional existing service instances to wrap
|
|
39
|
+
* @returns Array of all reloadable service adapters
|
|
40
|
+
*/
|
|
41
|
+
export declare function createAllReloadableAdapters(config: UserConfig, existingServices?: ServiceInstances): ReloadableService[];
|
|
42
|
+
/**
|
|
43
|
+
* Get adapter by name from array
|
|
44
|
+
*/
|
|
45
|
+
export declare function getAdapterByName<T extends ReloadableService>(adapters: ReloadableService[], name: string): T | undefined;
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/reloadable/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,4BAA4B,EAA+B,MAAM,sCAAsC,CAAC;AACjH,OAAO,EAAE,sBAAsB,EAAyB,MAAM,+BAA+B,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAA+B,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,oBAAoB,EAA0B,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAyB,MAAM,gCAAgC,CAAC;AAC/F,OAAO,EAAE,qBAAqB,EAAwB,MAAM,8BAA8B,CAAC;AAE3F;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qBAAqB,CAAC,EAAE,4BAA4B,CAAC;IACrD,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC,cAAc,CAAC,EAAE,qBAAqB,CAAC;CACxC;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,UAAU,EAClB,gBAAgB,CAAC,EAAE,gBAAgB,GAClC,iBAAiB,EAAE,CA2DrB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,iBAAiB,EAC1D,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,SAAS,CAEf"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reloadable Service Adapters
|
|
3
|
+
*
|
|
4
|
+
* Barrel export for all reloadable service adapters and factory function.
|
|
5
|
+
*/
|
|
6
|
+
// Adapter exports
|
|
7
|
+
export { CalendarSourceManagerAdapter, createCalendarSourceManager, } from './calendar-source-manager-adapter.js';
|
|
8
|
+
export { ReminderManagerAdapter, createReminderManager, } from './reminder-manager-adapter.js';
|
|
9
|
+
export { WorkingCadenceAdapter, createWorkingCadenceService, } from './working-cadence-adapter.js';
|
|
10
|
+
export { NotionServiceAdapter, createNotionMCPService, } from './notion-service-adapter.js';
|
|
11
|
+
export { TodoListManagerAdapter, createTodoListManager, } from './todo-list-manager-adapter.js';
|
|
12
|
+
export { PriorityEngineAdapter, PriorityEngineWrapper, createPriorityEngine, } from './priority-engine-adapter.js';
|
|
13
|
+
import { CalendarSourceManagerAdapter, createCalendarSourceManager } from './calendar-source-manager-adapter.js';
|
|
14
|
+
import { ReminderManagerAdapter, createReminderManager } from './reminder-manager-adapter.js';
|
|
15
|
+
import { WorkingCadenceAdapter, createWorkingCadenceService } from './working-cadence-adapter.js';
|
|
16
|
+
import { NotionServiceAdapter, createNotionMCPService } from './notion-service-adapter.js';
|
|
17
|
+
import { TodoListManagerAdapter, createTodoListManager } from './todo-list-manager-adapter.js';
|
|
18
|
+
import { PriorityEngineAdapter, createPriorityEngine } from './priority-engine-adapter.js';
|
|
19
|
+
/**
|
|
20
|
+
* Create all reloadable service adapters
|
|
21
|
+
*
|
|
22
|
+
* Factory function that creates all service adapters with their default factories.
|
|
23
|
+
* Optionally accepts existing service instances to wrap.
|
|
24
|
+
*
|
|
25
|
+
* @param config - User configuration to initialize services with
|
|
26
|
+
* @param existingServices - Optional existing service instances to wrap
|
|
27
|
+
* @returns Array of all reloadable service adapters
|
|
28
|
+
*/
|
|
29
|
+
export function createAllReloadableAdapters(config, existingServices) {
|
|
30
|
+
const adapters = [];
|
|
31
|
+
// CalendarSourceManager adapter
|
|
32
|
+
const calendarAdapter = existingServices?.calendarSourceManager
|
|
33
|
+
?? new CalendarSourceManagerAdapter(createCalendarSourceManager);
|
|
34
|
+
if (!existingServices?.calendarSourceManager) {
|
|
35
|
+
// Initialize with config if not using existing
|
|
36
|
+
calendarAdapter.reinitialize(config);
|
|
37
|
+
}
|
|
38
|
+
adapters.push(calendarAdapter);
|
|
39
|
+
// ReminderManager adapter
|
|
40
|
+
const reminderAdapter = existingServices?.reminderManager
|
|
41
|
+
?? new ReminderManagerAdapter(createReminderManager);
|
|
42
|
+
if (!existingServices?.reminderManager) {
|
|
43
|
+
reminderAdapter.reinitialize(config);
|
|
44
|
+
}
|
|
45
|
+
adapters.push(reminderAdapter);
|
|
46
|
+
// WorkingCadenceService adapter
|
|
47
|
+
// Note: Gets CalendarSourceManager after it's initialized
|
|
48
|
+
const workingCadenceAdapter = existingServices?.workingCadence
|
|
49
|
+
?? new WorkingCadenceAdapter(createWorkingCadenceService);
|
|
50
|
+
if (!existingServices?.workingCadence) {
|
|
51
|
+
// Set CalendarSourceManager dependency if available
|
|
52
|
+
const calendarInstance = calendarAdapter.getInstance();
|
|
53
|
+
if (calendarInstance) {
|
|
54
|
+
workingCadenceAdapter.setCalendarSourceManager(calendarInstance);
|
|
55
|
+
}
|
|
56
|
+
workingCadenceAdapter.reinitialize(config);
|
|
57
|
+
}
|
|
58
|
+
adapters.push(workingCadenceAdapter);
|
|
59
|
+
// NotionMCPService adapter
|
|
60
|
+
const notionAdapter = existingServices?.notionService
|
|
61
|
+
?? new NotionServiceAdapter(createNotionMCPService);
|
|
62
|
+
if (!existingServices?.notionService) {
|
|
63
|
+
notionAdapter.reinitialize(config);
|
|
64
|
+
}
|
|
65
|
+
adapters.push(notionAdapter);
|
|
66
|
+
// TodoListManager adapter
|
|
67
|
+
const todoAdapter = existingServices?.todoListManager
|
|
68
|
+
?? new TodoListManagerAdapter(createTodoListManager);
|
|
69
|
+
if (!existingServices?.todoListManager) {
|
|
70
|
+
todoAdapter.reinitialize(config);
|
|
71
|
+
}
|
|
72
|
+
adapters.push(todoAdapter);
|
|
73
|
+
// PriorityEngine adapter
|
|
74
|
+
const priorityAdapter = existingServices?.priorityEngine
|
|
75
|
+
?? new PriorityEngineAdapter(createPriorityEngine);
|
|
76
|
+
if (!existingServices?.priorityEngine) {
|
|
77
|
+
priorityAdapter.reinitialize(config);
|
|
78
|
+
}
|
|
79
|
+
adapters.push(priorityAdapter);
|
|
80
|
+
return adapters;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get adapter by name from array
|
|
84
|
+
*/
|
|
85
|
+
export function getAdapterByName(adapters, name) {
|
|
86
|
+
return adapters.find((a) => a.name === name);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/reloadable/index.ts"],"names":[],"mappings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CAAC;IACnC,CAAC;IACD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAE3B,yBAAyB;IACzB,MAAM,eAAe,GAAG,gBAAgB,EAAE,cAAc;WACnD,IAAI,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;IACrD,IAAI,CAAC,gBAAgB,EAAE,cAAc,EAAE,CAAC;QACtC,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IACD,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAE/B,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAA6B,EAC7B,IAAY;IAEZ,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAkB,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reloadable Service Adapter for NotionMCPService
|
|
3
|
+
*
|
|
4
|
+
* Wraps NotionMCPService to support hot-reload functionality.
|
|
5
|
+
* Reinitializes the service when integrations config changes.
|
|
6
|
+
*/
|
|
7
|
+
import type { ReloadableService } from '../../types/hot-reload.js';
|
|
8
|
+
import type { UserConfig } from '../../types/config.js';
|
|
9
|
+
import { NotionMCPService } from '../../integrations/notion-mcp.js';
|
|
10
|
+
/**
|
|
11
|
+
* Factory function type for creating NotionMCPService
|
|
12
|
+
*/
|
|
13
|
+
export type NotionMCPServiceFactory = (config: UserConfig) => NotionMCPService;
|
|
14
|
+
/**
|
|
15
|
+
* Default factory that creates NotionMCPService from UserConfig
|
|
16
|
+
*/
|
|
17
|
+
export declare function createNotionMCPService(config: UserConfig): NotionMCPService;
|
|
18
|
+
/**
|
|
19
|
+
* Reloadable adapter for NotionMCPService
|
|
20
|
+
*/
|
|
21
|
+
export declare class NotionServiceAdapter implements ReloadableService {
|
|
22
|
+
readonly name = "NotionMCPService";
|
|
23
|
+
readonly dependsOnSections: readonly string[];
|
|
24
|
+
private instance;
|
|
25
|
+
private factory;
|
|
26
|
+
/**
|
|
27
|
+
* Constructor
|
|
28
|
+
* @param factoryOrInstance - Either a factory function or an existing instance
|
|
29
|
+
*/
|
|
30
|
+
constructor(factoryOrInstance: NotionMCPServiceFactory | NotionMCPService);
|
|
31
|
+
/**
|
|
32
|
+
* Get the current NotionMCPService instance
|
|
33
|
+
*/
|
|
34
|
+
getInstance(): NotionMCPService | null;
|
|
35
|
+
/**
|
|
36
|
+
* Shutdown the current instance
|
|
37
|
+
* Disconnects MCP client if connected
|
|
38
|
+
*/
|
|
39
|
+
shutdown(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Reinitialize with new configuration
|
|
42
|
+
*/
|
|
43
|
+
reinitialize(config: UserConfig): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=notion-service-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notion-service-adapter.d.ts","sourceRoot":"","sources":["../../../src/services/reloadable/notion-service-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,kCAAkC,CAAC;AAKrF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,gBAAgB,CAAC;AAE/E;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB,CAY3E;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,iBAAiB;IAC5D,QAAQ,CAAC,IAAI,sBAAsB;IACnC,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAoB;IAEjE,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,OAAO,CAA0B;IAEzC;;;OAGG;gBACS,iBAAiB,EAAE,uBAAuB,GAAG,gBAAgB;IASzE;;OAEG;IACH,WAAW,IAAI,gBAAgB,GAAG,IAAI;IAItC;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB/B;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAWtD"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reloadable Service Adapter for NotionMCPService
|
|
3
|
+
*
|
|
4
|
+
* Wraps NotionMCPService to support hot-reload functionality.
|
|
5
|
+
* Reinitializes the service when integrations config changes.
|
|
6
|
+
*/
|
|
7
|
+
import { NotionMCPService, NotionMCPClient } from '../../integrations/notion-mcp.js';
|
|
8
|
+
import { createLogger } from '../../utils/logger.js';
|
|
9
|
+
const logger = createLogger('NotionServiceAdapter');
|
|
10
|
+
/**
|
|
11
|
+
* Default factory that creates NotionMCPService from UserConfig
|
|
12
|
+
*/
|
|
13
|
+
export function createNotionMCPService(config) {
|
|
14
|
+
const service = new NotionMCPService();
|
|
15
|
+
// Configure MCP client if Notion is enabled and database ID is set
|
|
16
|
+
if (config.integrations.notion.enabled && config.integrations.notion.databaseId) {
|
|
17
|
+
const client = new NotionMCPClient({
|
|
18
|
+
allowedDatabaseIds: [config.integrations.notion.databaseId],
|
|
19
|
+
});
|
|
20
|
+
service.setMCPClient(client);
|
|
21
|
+
}
|
|
22
|
+
return service;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Reloadable adapter for NotionMCPService
|
|
26
|
+
*/
|
|
27
|
+
export class NotionServiceAdapter {
|
|
28
|
+
name = 'NotionMCPService';
|
|
29
|
+
dependsOnSections = ['integrations'];
|
|
30
|
+
instance = null;
|
|
31
|
+
factory;
|
|
32
|
+
/**
|
|
33
|
+
* Constructor
|
|
34
|
+
* @param factoryOrInstance - Either a factory function or an existing instance
|
|
35
|
+
*/
|
|
36
|
+
constructor(factoryOrInstance) {
|
|
37
|
+
if (typeof factoryOrInstance === 'function') {
|
|
38
|
+
this.factory = factoryOrInstance;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this.instance = factoryOrInstance;
|
|
42
|
+
this.factory = createNotionMCPService;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the current NotionMCPService instance
|
|
47
|
+
*/
|
|
48
|
+
getInstance() {
|
|
49
|
+
return this.instance;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Shutdown the current instance
|
|
53
|
+
* Disconnects MCP client if connected
|
|
54
|
+
*/
|
|
55
|
+
async shutdown() {
|
|
56
|
+
logger.debug('Shutting down NotionMCPService');
|
|
57
|
+
if (this.instance) {
|
|
58
|
+
const client = this.instance.getMCPClient();
|
|
59
|
+
if (client && client.isConnected()) {
|
|
60
|
+
try {
|
|
61
|
+
await client.disconnect();
|
|
62
|
+
logger.debug('NotionMCPClient disconnected');
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
logger.warn({ err: error }, 'Error disconnecting NotionMCPClient');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
this.instance = null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Reinitialize with new configuration
|
|
73
|
+
*/
|
|
74
|
+
async reinitialize(config) {
|
|
75
|
+
logger.info('Reinitializing NotionMCPService with new config');
|
|
76
|
+
try {
|
|
77
|
+
this.instance = this.factory(config);
|
|
78
|
+
logger.info('NotionMCPService reinitialized successfully');
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
logger.error({ err: error }, 'Failed to reinitialize NotionMCPService');
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=notion-service-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notion-service-adapter.js","sourceRoot":"","sources":["../../../src/services/reloadable/notion-service-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,MAAM,GAAG,YAAY,CAAC,sBAAsB,CAAC,CAAC;AAOpD;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAkB;IACvD,MAAM,OAAO,GAAG,IAAI,gBAAgB,EAAE,CAAC;IAEvC,mEAAmE;IACnE,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QAChF,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;YACjC,kBAAkB,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC;SAC5D,CAAC,CAAC;QACH,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,oBAAoB;IACtB,IAAI,GAAG,kBAAkB,CAAC;IAC1B,iBAAiB,GAAsB,CAAC,cAAc,CAAC,CAAC;IAEzD,QAAQ,GAA4B,IAAI,CAAC;IACzC,OAAO,CAA0B;IAEzC;;;OAGG;IACH,YAAY,iBAA6D;QACvE,IAAI,OAAO,iBAAiB,KAAK,UAAU,EAAE,CAAC;YAC5C,IAAI,CAAC,OAAO,GAAG,iBAAiB,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,iBAAiB,CAAC;YAClC,IAAI,CAAC,OAAO,GAAG,sBAAsB,CAAC;QACxC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ;QACZ,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAE/C,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;YAC5C,IAAI,MAAM,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;gBACnC,IAAI,CAAC;oBACH,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;oBAC1B,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;gBAC/C,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,qCAAqC,CAAC,CAAC;gBACrE,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,MAAkB;QACnC,MAAM,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;QAE/D,IAAI,CAAC;YACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrC,MAAM,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;QAC7D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,yCAAyC,CAAC,CAAC;YACxE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reloadable Service Adapter for PriorityEngine
|
|
3
|
+
*
|
|
4
|
+
* Wraps PriorityEngine to support hot-reload functionality.
|
|
5
|
+
* Reinitializes the service when priorityRules config changes.
|
|
6
|
+
*
|
|
7
|
+
* Note: PriorityEngine is a stateless class with static methods,
|
|
8
|
+
* so shutdown/reinitialize are essentially no-ops. The adapter
|
|
9
|
+
* maintains a config reference that can be updated.
|
|
10
|
+
*/
|
|
11
|
+
import type { ReloadableService } from '../../types/hot-reload.js';
|
|
12
|
+
import type { UserConfig, PriorityRules, TeamConfig } from '../../types/config.js';
|
|
13
|
+
import { PriorityEngine } from '../../utils/priority.js';
|
|
14
|
+
/**
|
|
15
|
+
* PriorityEngine wrapper that holds config reference
|
|
16
|
+
*
|
|
17
|
+
* Since PriorityEngine uses static methods, this wrapper provides
|
|
18
|
+
* instance methods that use the stored config.
|
|
19
|
+
*/
|
|
20
|
+
export declare class PriorityEngineWrapper {
|
|
21
|
+
private priorityRules;
|
|
22
|
+
private teamConfig?;
|
|
23
|
+
constructor(config: UserConfig);
|
|
24
|
+
/**
|
|
25
|
+
* Get the current priority rules
|
|
26
|
+
*/
|
|
27
|
+
getPriorityRules(): PriorityRules;
|
|
28
|
+
/**
|
|
29
|
+
* Get the team config
|
|
30
|
+
*/
|
|
31
|
+
getTeamConfig(): TeamConfig | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Access to the underlying static PriorityEngine class
|
|
34
|
+
*/
|
|
35
|
+
get engine(): typeof PriorityEngine;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Factory function type for creating PriorityEngineWrapper
|
|
39
|
+
*/
|
|
40
|
+
export type PriorityEngineFactory = (config: UserConfig) => PriorityEngineWrapper;
|
|
41
|
+
/**
|
|
42
|
+
* Default factory that creates PriorityEngineWrapper from UserConfig
|
|
43
|
+
*/
|
|
44
|
+
export declare function createPriorityEngine(config: UserConfig): PriorityEngineWrapper;
|
|
45
|
+
/**
|
|
46
|
+
* Reloadable adapter for PriorityEngine
|
|
47
|
+
*/
|
|
48
|
+
export declare class PriorityEngineAdapter implements ReloadableService {
|
|
49
|
+
readonly name = "PriorityEngine";
|
|
50
|
+
readonly dependsOnSections: readonly string[];
|
|
51
|
+
private instance;
|
|
52
|
+
private factory;
|
|
53
|
+
/**
|
|
54
|
+
* Constructor
|
|
55
|
+
* @param factoryOrInstance - Either a factory function or an existing instance
|
|
56
|
+
*/
|
|
57
|
+
constructor(factoryOrInstance: PriorityEngineFactory | PriorityEngineWrapper);
|
|
58
|
+
/**
|
|
59
|
+
* Get the current PriorityEngineWrapper instance
|
|
60
|
+
*/
|
|
61
|
+
getInstance(): PriorityEngineWrapper | null;
|
|
62
|
+
/**
|
|
63
|
+
* Shutdown the current instance
|
|
64
|
+
* PriorityEngine is stateless, so this is a no-op
|
|
65
|
+
*/
|
|
66
|
+
shutdown(): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Reinitialize with new configuration
|
|
69
|
+
* Updates the config reference for the wrapper
|
|
70
|
+
*/
|
|
71
|
+
reinitialize(config: UserConfig): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=priority-engine-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"priority-engine-adapter.d.ts","sourceRoot":"","sources":["../../../src/services/reloadable/priority-engine-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAKzD;;;;;GAKG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,UAAU,CAAC,CAAa;gBAEpB,MAAM,EAAE,UAAU;IAK9B;;OAEG;IACH,gBAAgB,IAAI,aAAa;IAIjC;;OAEG;IACH,aAAa,IAAI,UAAU,GAAG,SAAS;IAIvC;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,cAAc,CAElC;CACF;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,qBAAqB,CAAC;AAElF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,qBAAqB,CAE9E;AAED;;GAEG;AACH,qBAAa,qBAAsB,YAAW,iBAAiB;IAC7D,QAAQ,CAAC,IAAI,oBAAoB;IACjC,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAqB;IAElE,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,OAAO,CAAwB;IAEvC;;;OAGG;gBACS,iBAAiB,EAAE,qBAAqB,GAAG,qBAAqB;IAS5E;;OAEG;IACH,WAAW,IAAI,qBAAqB,GAAG,IAAI;IAI3C;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAO/B;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAWtD"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reloadable Service Adapter for PriorityEngine
|
|
3
|
+
*
|
|
4
|
+
* Wraps PriorityEngine to support hot-reload functionality.
|
|
5
|
+
* Reinitializes the service when priorityRules config changes.
|
|
6
|
+
*
|
|
7
|
+
* Note: PriorityEngine is a stateless class with static methods,
|
|
8
|
+
* so shutdown/reinitialize are essentially no-ops. The adapter
|
|
9
|
+
* maintains a config reference that can be updated.
|
|
10
|
+
*/
|
|
11
|
+
import { PriorityEngine } from '../../utils/priority.js';
|
|
12
|
+
import { createLogger } from '../../utils/logger.js';
|
|
13
|
+
const logger = createLogger('PriorityEngineAdapter');
|
|
14
|
+
/**
|
|
15
|
+
* PriorityEngine wrapper that holds config reference
|
|
16
|
+
*
|
|
17
|
+
* Since PriorityEngine uses static methods, this wrapper provides
|
|
18
|
+
* instance methods that use the stored config.
|
|
19
|
+
*/
|
|
20
|
+
export class PriorityEngineWrapper {
|
|
21
|
+
priorityRules;
|
|
22
|
+
teamConfig;
|
|
23
|
+
constructor(config) {
|
|
24
|
+
this.priorityRules = config.priorityRules;
|
|
25
|
+
this.teamConfig = config.team;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get the current priority rules
|
|
29
|
+
*/
|
|
30
|
+
getPriorityRules() {
|
|
31
|
+
return this.priorityRules;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the team config
|
|
35
|
+
*/
|
|
36
|
+
getTeamConfig() {
|
|
37
|
+
return this.teamConfig;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Access to the underlying static PriorityEngine class
|
|
41
|
+
*/
|
|
42
|
+
get engine() {
|
|
43
|
+
return PriorityEngine;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Default factory that creates PriorityEngineWrapper from UserConfig
|
|
48
|
+
*/
|
|
49
|
+
export function createPriorityEngine(config) {
|
|
50
|
+
return new PriorityEngineWrapper(config);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Reloadable adapter for PriorityEngine
|
|
54
|
+
*/
|
|
55
|
+
export class PriorityEngineAdapter {
|
|
56
|
+
name = 'PriorityEngine';
|
|
57
|
+
dependsOnSections = ['priorityRules'];
|
|
58
|
+
instance = null;
|
|
59
|
+
factory;
|
|
60
|
+
/**
|
|
61
|
+
* Constructor
|
|
62
|
+
* @param factoryOrInstance - Either a factory function or an existing instance
|
|
63
|
+
*/
|
|
64
|
+
constructor(factoryOrInstance) {
|
|
65
|
+
if (typeof factoryOrInstance === 'function') {
|
|
66
|
+
this.factory = factoryOrInstance;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this.instance = factoryOrInstance;
|
|
70
|
+
this.factory = createPriorityEngine;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get the current PriorityEngineWrapper instance
|
|
75
|
+
*/
|
|
76
|
+
getInstance() {
|
|
77
|
+
return this.instance;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Shutdown the current instance
|
|
81
|
+
* PriorityEngine is stateless, so this is a no-op
|
|
82
|
+
*/
|
|
83
|
+
async shutdown() {
|
|
84
|
+
logger.debug('Shutting down PriorityEngine (no-op for stateless engine)');
|
|
85
|
+
// PriorityEngine is stateless, no cleanup needed
|
|
86
|
+
// Just clear the reference
|
|
87
|
+
this.instance = null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Reinitialize with new configuration
|
|
91
|
+
* Updates the config reference for the wrapper
|
|
92
|
+
*/
|
|
93
|
+
async reinitialize(config) {
|
|
94
|
+
logger.info('Reinitializing PriorityEngine with new config');
|
|
95
|
+
try {
|
|
96
|
+
this.instance = this.factory(config);
|
|
97
|
+
logger.info('PriorityEngine reinitialized successfully');
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
logger.error({ err: error }, 'Failed to reinitialize PriorityEngine');
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=priority-engine-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"priority-engine-adapter.js","sourceRoot":"","sources":["../../../src/services/reloadable/priority-engine-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,MAAM,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAErD;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IACxB,aAAa,CAAgB;IAC7B,UAAU,CAAc;IAEhC,YAAY,MAAkB;QAC5B,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;QAC1C,IAAI,CAAC,UAAU,GAAG,M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AAC;YACrC,MAAM,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,uCAAuC,CAAC,CAAC;YACtE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reloadable Service Adapter for ReminderManager
|
|
3
|
+
*
|
|
4
|
+
* Wraps ReminderManager to support hot-reload functionality.
|
|
5
|
+
* Reinitializes the service when integrations or reminders config changes.
|
|
6
|
+
*/
|
|
7
|
+
import type { ReloadableService } from '../../types/hot-reload.js';
|
|
8
|
+
import type { UserConfig } from '../../types/config.js';
|
|
9
|
+
import { ReminderManager } from '../../integrations/reminder-manager.js';
|
|
10
|
+
/**
|
|
11
|
+
* Factory function type for creating ReminderManager
|
|
12
|
+
*/
|
|
13
|
+
export type ReminderManagerFactory = (config: UserConfig) => ReminderManager;
|
|
14
|
+
/**
|
|
15
|
+
* Default factory that creates ReminderManager from UserConfig
|
|
16
|
+
*/
|
|
17
|
+
export declare function createReminderManager(config: UserConfig): ReminderManager;
|
|
18
|
+
/**
|
|
19
|
+
* Reloadable adapter for ReminderManager
|
|
20
|
+
*/
|
|
21
|
+
export declare class ReminderManagerAdapter implements ReloadableService {
|
|
22
|
+
readonly name = "ReminderManager";
|
|
23
|
+
readonly dependsOnSections: readonly string[];
|
|
24
|
+
private instance;
|
|
25
|
+
private factory;
|
|
26
|
+
/**
|
|
27
|
+
* Constructor
|
|
28
|
+
* @param factoryOrInstance - Either a factory function or an existing instance
|
|
29
|
+
*/
|
|
30
|
+
constructor(factoryOrInstance: ReminderManagerFactory | ReminderManager);
|
|
31
|
+
/**
|
|
32
|
+
* Get the current ReminderManager instance
|
|
33
|
+
*/
|
|
34
|
+
getInstance(): ReminderManager | null;
|
|
35
|
+
/**
|
|
36
|
+
* Shutdown the current instance
|
|
37
|
+
* ReminderManager does not have explicit cleanup needs
|
|
38
|
+
*/
|
|
39
|
+
shutdown(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Reinitialize with new configuration
|
|
42
|
+
*/
|
|
43
|
+
reinitialize(config: UserConfig): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=reminder-manager-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reminder-manager-adapter.d.ts","sourceRoot":"","sources":["../../../src/services/reloadable/reminder-manager-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAkB,MAAM,wCAAwC,CAAC;AAKzF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,eAAe,CAAC;AAc7E;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,eAAe,CAGzE;AAED;;GAEG;AACH,qBAAa,sBAAuB,YAAW,iBAAiB;IAC9D,QAAQ,CAAC,IAAI,qBAAqB;IAClC,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAiC;IAE9E,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,OAAO,CAAyB;IAExC;;;OAGG;gBACS,iBAAiB,EAAE,sBAAsB,GAAG,eAAe;IASvE;;OAEG;IACH,WAAW,IAAI,eAAe,GAAG,IAAI;IAIrC;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAO/B;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAWtD"}
|