@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,80 @@
|
|
|
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 { ReminderManager } from '../../integrations/reminder-manager.js';
|
|
8
|
+
import { createLogger } from '../../utils/logger.js';
|
|
9
|
+
const logger = createLogger('ReminderManagerAdapter');
|
|
10
|
+
/**
|
|
11
|
+
* Extract ReminderConfig from UserConfig
|
|
12
|
+
*/
|
|
13
|
+
function extractReminderConfig(config) {
|
|
14
|
+
return {
|
|
15
|
+
appleRemindersThreshold: config.integrations.appleReminders.threshold,
|
|
16
|
+
notionThreshold: config.integrations.notion.threshold,
|
|
17
|
+
defaultList: config.integrations.appleReminders.defaultList,
|
|
18
|
+
notionDatabaseId: config.integrations.notion.databaseId,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Default factory that creates ReminderManager from UserConfig
|
|
23
|
+
*/
|
|
24
|
+
export function createReminderManager(config) {
|
|
25
|
+
const reminderConfig = extractReminderConfig(config);
|
|
26
|
+
return new ReminderManager(reminderConfig);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Reloadable adapter for ReminderManager
|
|
30
|
+
*/
|
|
31
|
+
export class ReminderManagerAdapter {
|
|
32
|
+
name = 'ReminderManager';
|
|
33
|
+
dependsOnSections = ['integrations', 'reminders'];
|
|
34
|
+
instance = null;
|
|
35
|
+
factory;
|
|
36
|
+
/**
|
|
37
|
+
* Constructor
|
|
38
|
+
* @param factoryOrInstance - Either a factory function or an existing instance
|
|
39
|
+
*/
|
|
40
|
+
constructor(factoryOrInstance) {
|
|
41
|
+
if (typeof factoryOrInstance === 'function') {
|
|
42
|
+
this.factory = factoryOrInstance;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.instance = factoryOrInstance;
|
|
46
|
+
this.factory = createReminderManager;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the current ReminderManager instance
|
|
51
|
+
*/
|
|
52
|
+
getInstance() {
|
|
53
|
+
return this.instance;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Shutdown the current instance
|
|
57
|
+
* ReminderManager does not have explicit cleanup needs
|
|
58
|
+
*/
|
|
59
|
+
async shutdown() {
|
|
60
|
+
logger.debug('Shutting down ReminderManager');
|
|
61
|
+
// ReminderManager has no explicit cleanup
|
|
62
|
+
// Just clear the reference
|
|
63
|
+
this.instance = null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Reinitialize with new configuration
|
|
67
|
+
*/
|
|
68
|
+
async reinitialize(config) {
|
|
69
|
+
logger.info('Reinitializing ReminderManager with new config');
|
|
70
|
+
try {
|
|
71
|
+
this.instance = this.factory(config);
|
|
72
|
+
logger.info('ReminderManager reinitialized successfully');
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
logger.error({ err: error }, 'Failed to reinitialize ReminderManager');
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=reminder-manager-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reminder-manager-adapter.js","sourceRoot":"","sources":["../../../src/services/reloadable/reminder-manager-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,eAAe,EAAkB,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,MAAM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AED;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,MAAkB;QACnC,MAAM,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QAE9D,IAAI,CAAC;YACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrC,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,wCAAwC,CAAC,CAAC;YACvE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reloadable Service Adapter for TodoListManager
|
|
3
|
+
*
|
|
4
|
+
* Wraps TodoListManager 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 { TodoListManager } from '../../integrations/todo-list-manager.js';
|
|
10
|
+
/**
|
|
11
|
+
* Factory function type for creating TodoListManager
|
|
12
|
+
*/
|
|
13
|
+
export type TodoListManagerFactory = (config: UserConfig) => TodoListManager;
|
|
14
|
+
/**
|
|
15
|
+
* Default factory that creates TodoListManager from UserConfig
|
|
16
|
+
*/
|
|
17
|
+
export declare function createTodoListManager(config: UserConfig): TodoListManager;
|
|
18
|
+
/**
|
|
19
|
+
* Reloadable adapter for TodoListManager
|
|
20
|
+
*/
|
|
21
|
+
export declare class TodoListManagerAdapter implements ReloadableService {
|
|
22
|
+
readonly name = "TodoListManager";
|
|
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: TodoListManagerFactory | TodoListManager);
|
|
31
|
+
/**
|
|
32
|
+
* Get the current TodoListManager instance
|
|
33
|
+
*/
|
|
34
|
+
getInstance(): TodoListManager | null;
|
|
35
|
+
/**
|
|
36
|
+
* Shutdown the current instance
|
|
37
|
+
* TodoListManager 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=todo-list-manager-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo-list-manager-adapter.d.ts","sourceRoot":"","sources":["../../../src/services/reloadable/todo-list-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,EAAyB,MAAM,yCAAyC,CAAC;AAKjG;;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,CAAoB;IAEjE,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"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reloadable Service Adapter for TodoListManager
|
|
3
|
+
*
|
|
4
|
+
* Wraps TodoListManager to support hot-reload functionality.
|
|
5
|
+
* Reinitializes the service when integrations config changes.
|
|
6
|
+
*/
|
|
7
|
+
import { TodoListManager } from '../../integrations/todo-list-manager.js';
|
|
8
|
+
import { createLogger } from '../../utils/logger.js';
|
|
9
|
+
const logger = createLogger('TodoListManagerAdapter');
|
|
10
|
+
/**
|
|
11
|
+
* Extract TodoListManagerConfig from UserConfig
|
|
12
|
+
*/
|
|
13
|
+
function extractTodoListManagerConfig(config) {
|
|
14
|
+
return {
|
|
15
|
+
notionDatabaseId: config.integrations.notion.enabled
|
|
16
|
+
? config.integrations.notion.databaseId
|
|
17
|
+
: undefined,
|
|
18
|
+
appleRemindersDefaultList: config.integrations.appleReminders.defaultList,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Default factory that creates TodoListManager from UserConfig
|
|
23
|
+
*/
|
|
24
|
+
export function createTodoListManager(config) {
|
|
25
|
+
const todoConfig = extractTodoListManagerConfig(config);
|
|
26
|
+
return new TodoListManager(todoConfig);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Reloadable adapter for TodoListManager
|
|
30
|
+
*/
|
|
31
|
+
export class TodoListManagerAdapter {
|
|
32
|
+
name = 'TodoListManager';
|
|
33
|
+
dependsOnSections = ['integrations'];
|
|
34
|
+
instance = null;
|
|
35
|
+
factory;
|
|
36
|
+
/**
|
|
37
|
+
* Constructor
|
|
38
|
+
* @param factoryOrInstance - Either a factory function or an existing instance
|
|
39
|
+
*/
|
|
40
|
+
constructor(factoryOrInstance) {
|
|
41
|
+
if (typeof factoryOrInstance === 'function') {
|
|
42
|
+
this.factory = factoryOrInstance;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.instance = factoryOrInstance;
|
|
46
|
+
this.factory = createTodoListManager;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the current TodoListManager instance
|
|
51
|
+
*/
|
|
52
|
+
getInstance() {
|
|
53
|
+
return this.instance;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Shutdown the current instance
|
|
57
|
+
* TodoListManager does not have explicit cleanup needs
|
|
58
|
+
*/
|
|
59
|
+
async shutdown() {
|
|
60
|
+
logger.debug('Shutting down TodoListManager');
|
|
61
|
+
// TodoListManager has no explicit cleanup (cache will be garbage collected)
|
|
62
|
+
// Just clear the reference
|
|
63
|
+
this.instance = null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Reinitialize with new configuration
|
|
67
|
+
*/
|
|
68
|
+
async reinitialize(config) {
|
|
69
|
+
logger.info('Reinitializing TodoListManager with new config');
|
|
70
|
+
try {
|
|
71
|
+
this.instance = this.factory(config);
|
|
72
|
+
logger.info('TodoListManager reinitialized successfully');
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
logger.error({ err: error }, 'Failed to reinitialize TodoListManager');
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=todo-list-manager-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo-list-manager-adapter.js","sourceRoot":"","sources":["../../../src/services/reloadable/todo-list-manager-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,eAAe,EAAyB,MAAM,yCAAyC,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,MAAM,GAAG,YAAY,CAAC,wBAAwB,C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AgD,CAAC,CAAC;QAE9D,IAAI,CAAC;YACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrC,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,wCAAwC,CAAC,CAAC;YACvE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reloadable Service Adapter for WorkingCadenceService
|
|
3
|
+
*
|
|
4
|
+
* Wraps WorkingCadenceService to support hot-reload functionality.
|
|
5
|
+
* Reinitializes the service when calendar config changes.
|
|
6
|
+
*/
|
|
7
|
+
import type { ReloadableService } from '../../types/hot-reload.js';
|
|
8
|
+
import type { UserConfig } from '../../types/config.js';
|
|
9
|
+
import { WorkingCadenceService } from '../working-cadence.js';
|
|
10
|
+
import type { CalendarSourceManager } from '../../integrations/calendar-source-manager.js';
|
|
11
|
+
/**
|
|
12
|
+
* Factory function type for creating WorkingCadenceService
|
|
13
|
+
*/
|
|
14
|
+
export type WorkingCadenceServiceFactory = (config: UserConfig, calendarSourceManager?: CalendarSourceManager) => WorkingCadenceService;
|
|
15
|
+
/**
|
|
16
|
+
* Default factory that creates WorkingCadenceService
|
|
17
|
+
*/
|
|
18
|
+
export declare function createWorkingCadenceService(_config: UserConfig, calendarSourceManager?: CalendarSourceManager): WorkingCadenceService;
|
|
19
|
+
/**
|
|
20
|
+
* Reloadable adapter for WorkingCadenceService
|
|
21
|
+
*/
|
|
22
|
+
export declare class WorkingCadenceAdapter implements ReloadableService {
|
|
23
|
+
readonly name = "WorkingCadenceService";
|
|
24
|
+
readonly dependsOnSections: readonly string[];
|
|
25
|
+
private instance;
|
|
26
|
+
private factory;
|
|
27
|
+
private calendarSourceManager?;
|
|
28
|
+
/**
|
|
29
|
+
* Constructor
|
|
30
|
+
* @param factoryOrInstance - Either a factory function or an existing instance
|
|
31
|
+
* @param calendarSourceManager - Optional CalendarSourceManager for focusTime analysis
|
|
32
|
+
*/
|
|
33
|
+
constructor(factoryOrInstance: WorkingCadenceServiceFactory | WorkingCadenceService, calendarSourceManager?: CalendarSourceManager);
|
|
34
|
+
/**
|
|
35
|
+
* Set the CalendarSourceManager for dependency injection
|
|
36
|
+
*/
|
|
37
|
+
setCalendarSourceManager(manager: CalendarSourceManager): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get the current WorkingCadenceService instance
|
|
40
|
+
*/
|
|
41
|
+
getInstance(): WorkingCadenceService | null;
|
|
42
|
+
/**
|
|
43
|
+
* Shutdown the current instance
|
|
44
|
+
* WorkingCadenceService does not have explicit cleanup needs
|
|
45
|
+
*/
|
|
46
|
+
shutdown(): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Reinitialize with new configuration
|
|
49
|
+
*/
|
|
50
|
+
reinitialize(config: UserConfig): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=working-cadence-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-cadence-adapter.d.ts","sourceRoot":"","sources":["../../../src/services/reloadable/working-cadence-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,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AAK3F;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,CACzC,MAAM,EAAE,UAAU,EAClB,qBAAqB,CAAC,EAAE,qBAAqB,KAC1C,qBAAqB,CAAC;AAE3B;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,UAAU,EACnB,qBAAqB,CAAC,EAAE,qBAAqB,GAC5C,qBAAqB,CAEvB;AAED;;GAEG;AACH,qBAAa,qBAAsB,YAAW,iBAAiB;IAC7D,QAAQ,CAAC,IAAI,2BAA2B;IACxC,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAgB;IAE7D,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,qBAAqB,CAAC,CAAwB;IAEtD;;;;OAIG;gBAED,iBAAiB,EAAE,4BAA4B,GAAG,qBAAqB,EACvE,qBAAqB,CAAC,EAAE,qBAAqB;IAY/C;;OAEG;IACH,wBAAwB,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI;IAI9D;;OAEG;IACH,WAAW,IAAI,qBAAqB,GAAG,IAAI;IAI3C;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAO/B;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAWtD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reloadable Service Adapter for WorkingCadenceService
|
|
3
|
+
*
|
|
4
|
+
* Wraps WorkingCadenceService to support hot-reload functionality.
|
|
5
|
+
* Reinitializes the service when calendar config changes.
|
|
6
|
+
*/
|
|
7
|
+
import { WorkingCadenceService } from '../working-cadence.js';
|
|
8
|
+
import { createLogger } from '../../utils/logger.js';
|
|
9
|
+
const logger = createLogger('WorkingCadenceAdapter');
|
|
10
|
+
/**
|
|
11
|
+
* Default factory that creates WorkingCadenceService
|
|
12
|
+
*/
|
|
13
|
+
export function createWorkingCadenceService(_config, calendarSourceManager) {
|
|
14
|
+
return new WorkingCadenceService(calendarSourceManager);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Reloadable adapter for WorkingCadenceService
|
|
18
|
+
*/
|
|
19
|
+
export class WorkingCadenceAdapter {
|
|
20
|
+
name = 'WorkingCadenceService';
|
|
21
|
+
dependsOnSections = ['calendar'];
|
|
22
|
+
instance = null;
|
|
23
|
+
factory;
|
|
24
|
+
calendarSourceManager;
|
|
25
|
+
/**
|
|
26
|
+
* Constructor
|
|
27
|
+
* @param factoryOrInstance - Either a factory function or an existing instance
|
|
28
|
+
* @param calendarSourceManager - Optional CalendarSourceManager for focusTime analysis
|
|
29
|
+
*/
|
|
30
|
+
constructor(factoryOrInstance, calendarSourceManager) {
|
|
31
|
+
this.calendarSourceManager = calendarSourceManager;
|
|
32
|
+
if (typeof factoryOrInstance === 'function') {
|
|
33
|
+
this.factory = factoryOrInstance;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.instance = factoryOrInstance;
|
|
37
|
+
this.factory = createWorkingCadenceService;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Set the CalendarSourceManager for dependency injection
|
|
42
|
+
*/
|
|
43
|
+
setCalendarSourceManager(manager) {
|
|
44
|
+
this.calendarSourceManager = manager;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the current WorkingCadenceService instance
|
|
48
|
+
*/
|
|
49
|
+
getInstance() {
|
|
50
|
+
return this.instance;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Shutdown the current instance
|
|
54
|
+
* WorkingCadenceService does not have explicit cleanup needs
|
|
55
|
+
*/
|
|
56
|
+
async shutdown() {
|
|
57
|
+
logger.debug('Shutting down WorkingCadenceService');
|
|
58
|
+
// WorkingCadenceService has no explicit cleanup
|
|
59
|
+
// Just clear the reference
|
|
60
|
+
this.instance = null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Reinitialize with new configuration
|
|
64
|
+
*/
|
|
65
|
+
async reinitialize(config) {
|
|
66
|
+
logger.info('Reinitializing WorkingCadenceService with new config');
|
|
67
|
+
try {
|
|
68
|
+
this.instance = this.factory(config, this.calendarSourceManager);
|
|
69
|
+
logger.info('WorkingCadenceService reinitialized successfully');
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
logger.error({ err: error }, 'Failed to reinitialize WorkingCadenceService');
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=working-cadence-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-cadence-adapter.js","sourceRoot":"","sources":["../../../src/services/reloadable/working-cadence-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,MAAM,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAUrD;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAAmB,EACnB,qBAA6C;IAE7C,OAAO,IAAI,qBAAqB,CAAC,qBAAqB,CAAC,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,qBAAqB;IACvB,IAAI,GAAG,uBAAuB,CAAC;IAC/B,iBAAiB,GAAsB,CAAC,UAAU,CAAC,CAAC;IAErD,QAAQ,GAAiC,IAAI,CAAC;IAC9C,OAAO,CAA+B;IACtC,qBAAqB,CAAyB;IAEtD;;;;OAIG;IACH,YACE,iBAAuE,EACvE,qBAA6C;QAE7C,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QAEnD,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,wBAAwB,CAAC,OAA8B;QACrD,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC;IACvC,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,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC;YACjE,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,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ServiceRegistry
|
|
3
|
+
*
|
|
4
|
+
* Manages reloadable services lifecycle for hot-reload functionality.
|
|
5
|
+
* Provides registration, deregistration, and coordinated re-initialization
|
|
6
|
+
* of services when configuration changes.
|
|
7
|
+
*/
|
|
8
|
+
import type { ReloadableService } from '../types/hot-reload.js';
|
|
9
|
+
import type { UserConfig } from '../types/config.js';
|
|
10
|
+
/**
|
|
11
|
+
* Registry for managing reloadable services
|
|
12
|
+
*
|
|
13
|
+
* Services register themselves with the registry and declare which
|
|
14
|
+
* configuration sections they depend on. When those sections change,
|
|
15
|
+
* the registry coordinates shutting down and re-initializing affected services.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ServiceRegistry {
|
|
18
|
+
private services;
|
|
19
|
+
/**
|
|
20
|
+
* Register a service with the registry
|
|
21
|
+
*
|
|
22
|
+
* @param service - The reloadable service to register
|
|
23
|
+
* @throws Error if a service with the same name is already registered
|
|
24
|
+
*/
|
|
25
|
+
register(service: ReloadableService): void;
|
|
26
|
+
/**
|
|
27
|
+
* Unregister a service from the registry
|
|
28
|
+
*
|
|
29
|
+
* @param name - The name of the service to unregister
|
|
30
|
+
*/
|
|
31
|
+
unregister(name: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get all services that depend on any of the given configuration sections
|
|
34
|
+
*
|
|
35
|
+
* @param sections - Array of configuration section names
|
|
36
|
+
* @returns Array of services that depend on at least one of the sections
|
|
37
|
+
*/
|
|
38
|
+
getServicesForSections(sections: string[]): ReloadableService[];
|
|
39
|
+
/**
|
|
40
|
+
* Reinitialize all services affected by changes in the given sections
|
|
41
|
+
*
|
|
42
|
+
* Shuts down and re-initializes services sequentially to ensure
|
|
43
|
+
* proper ordering and error isolation. Errors in individual services
|
|
44
|
+
* are logged but do not prevent other services from re-initializing.
|
|
45
|
+
*
|
|
46
|
+
* @param sections - Array of changed configuration section names
|
|
47
|
+
* @param config - The new configuration to use for re-initialization
|
|
48
|
+
*/
|
|
49
|
+
reinitializeForSections(sections: string[], config: UserConfig): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Gracefully shutdown all registered services
|
|
52
|
+
*
|
|
53
|
+
* Iterates through all services and calls their shutdown method.
|
|
54
|
+
* Errors in individual services are logged but do not prevent
|
|
55
|
+
* other services from shutting down.
|
|
56
|
+
*/
|
|
57
|
+
shutdownAll(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Get the number of registered services
|
|
60
|
+
*
|
|
61
|
+
* @returns The count of registered services
|
|
62
|
+
*/
|
|
63
|
+
get size(): number;
|
|
64
|
+
/**
|
|
65
|
+
* Check if a service is registered
|
|
66
|
+
*
|
|
67
|
+
* @param name - The name of the service to check
|
|
68
|
+
* @returns True if the service is registered
|
|
69
|
+
*/
|
|
70
|
+
has(name: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Get a registered service by name
|
|
73
|
+
*
|
|
74
|
+
* @param name - The name of the service to get
|
|
75
|
+
* @returns The service if registered, undefined otherwise
|
|
76
|
+
*/
|
|
77
|
+
get(name: string): ReloadableService | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Get all registered service names
|
|
80
|
+
*
|
|
81
|
+
* @returns Array of registered service names
|
|
82
|
+
*/
|
|
83
|
+
getServiceNames(): string[];
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=service-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-registry.d.ts","sourceRoot":"","sources":["../../src/services/service-registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD;;;;;;GAMG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAA6C;IAE7D;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAkB1C;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAY9B;;;;;OAKG;IACH,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,iBAAiB,EAAE;IAgB/D;;;;;;;;;OASG;IACG,uBAAuB,CAC3B,QAAQ,EAAE,MAAM,EAAE,EAClB,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,IAAI,CAAC;IAqDhB;;;;;;OAMG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAuClC;;;;OAIG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAIhD;;;;OAIG;IACH,eAAe,IAAI,MAAM,EAAE;CAG5B"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ServiceRegistry
|
|
3
|
+
*
|
|
4
|
+
* Manages reloadable services lifecycle for hot-reload functionality.
|
|
5
|
+
* Provides registration, deregistration, and coordinated re-initialization
|
|
6
|
+
* of services when configuration changes.
|
|
7
|
+
*/
|
|
8
|
+
import { servicesLogger } from '../utils/logger.js';
|
|
9
|
+
/**
|
|
10
|
+
* Registry for managing reloadable services
|
|
11
|
+
*
|
|
12
|
+
* Services register themselves with the registry and declare which
|
|
13
|
+
* configuration sections they depend on. When those sections change,
|
|
14
|
+
* the registry coordinates shutting down and re-initializing affected services.
|
|
15
|
+
*/
|
|
16
|
+
export class ServiceRegistry {
|
|
17
|
+
services = new Map();
|
|
18
|
+
/**
|
|
19
|
+
* Register a service with the registry
|
|
20
|
+
*
|
|
21
|
+
* @param service - The reloadable service to register
|
|
22
|
+
* @throws Error if a service with the same name is already registered
|
|
23
|
+
*/
|
|
24
|
+
register(service) {
|
|
25
|
+
if (this.services.has(service.name)) {
|
|
26
|
+
servicesLogger.warn({ serviceName: service.name }, 'Service already registered, replacing existing registration');
|
|
27
|
+
}
|
|
28
|
+
this.services.set(service.name, service);
|
|
29
|
+
servicesLogger.info({
|
|
30
|
+
serviceName: service.name,
|
|
31
|
+
dependsOn: service.dependsOnSections,
|
|
32
|
+
}, 'Service registered');
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Unregister a service from the registry
|
|
36
|
+
*
|
|
37
|
+
* @param name - The name of the service to unregister
|
|
38
|
+
*/
|
|
39
|
+
unregister(name) {
|
|
40
|
+
if (this.services.has(name)) {
|
|
41
|
+
this.services.delete(name);
|
|
42
|
+
servicesLogger.info({ serviceName: name }, 'Service unregistered');
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
servicesLogger.warn({ serviceName: name }, 'Attempted to unregister non-existent service');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get all services that depend on any of the given configuration sections
|
|
50
|
+
*
|
|
51
|
+
* @param sections - Array of configuration section names
|
|
52
|
+
* @returns Array of services that depend on at least one of the sections
|
|
53
|
+
*/
|
|
54
|
+
getServicesForSections(sections) {
|
|
55
|
+
const affectedServices = [];
|
|
56
|
+
for (const service of this.services.values()) {
|
|
57
|
+
const hasMatchingSection = service.dependsOnSections.some((dep) => sections.includes(dep));
|
|
58
|
+
if (hasMatchingSection) {
|
|
59
|
+
affectedServices.push(service);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return affectedServices;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Reinitialize all services affected by changes in the given sections
|
|
66
|
+
*
|
|
67
|
+
* Shuts down and re-initializes services sequentially to ensure
|
|
68
|
+
* proper ordering and error isolation. Errors in individual services
|
|
69
|
+
* are logged but do not prevent other services from re-initializing.
|
|
70
|
+
*
|
|
71
|
+
* @param sections - Array of changed configuration section names
|
|
72
|
+
* @param config - The new configuration to use for re-initialization
|
|
73
|
+
*/
|
|
74
|
+
async reinitializeForSections(sections, config) {
|
|
75
|
+
const affectedServices = this.getServicesForSections(sections);
|
|
76
|
+
if (affectedServices.length === 0) {
|
|
77
|
+
servicesLogger.debug({ sections }, 'No services affected by configuration changes');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
servicesLogger.info({
|
|
81
|
+
sections,
|
|
82
|
+
serviceCount: affectedServices.length,
|
|
83
|
+
services: affectedServices.map((s) => s.name),
|
|
84
|
+
}, 'Reinitializing services for changed sections');
|
|
85
|
+
for (const service of affectedServices) {
|
|
86
|
+
try {
|
|
87
|
+
servicesLogger.debug({ serviceName: service.name }, 'Shutting down service for reinitialize');
|
|
88
|
+
await service.shutdown();
|
|
89
|
+
servicesLogger.debug({ serviceName: service.name }, 'Reinitializing service with new config');
|
|
90
|
+
await service.reinitialize(config);
|
|
91
|
+
servicesLogger.info({ serviceName: service.name }, 'Service reinitialized successfully');
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
// Error isolation: log the error but continue with other services
|
|
95
|
+
servicesLogger.error({
|
|
96
|
+
serviceName: service.name,
|
|
97
|
+
err: error,
|
|
98
|
+
}, 'Failed to reinitialize service');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Gracefully shutdown all registered services
|
|
104
|
+
*
|
|
105
|
+
* Iterates through all services and calls their shutdown method.
|
|
106
|
+
* Errors in individual services are logged but do not prevent
|
|
107
|
+
* other services from shutting down.
|
|
108
|
+
*/
|
|
109
|
+
async shutdownAll() {
|
|
110
|
+
if (this.services.size === 0) {
|
|
111
|
+
servicesLogger.debug('No services to shutdown');
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
servicesLogger.info({ serviceCount: this.services.size }, 'Shutting down all services');
|
|
115
|
+
for (const service of this.services.values()) {
|
|
116
|
+
try {
|
|
117
|
+
servicesLogger.debug({ serviceName: service.name }, 'Shutting down service');
|
|
118
|
+
await service.shutdown();
|
|
119
|
+
servicesLogger.info({ serviceName: service.name }, 'Service shutdown successfully');
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
// Error isolation: log the error but continue with other services
|
|
123
|
+
servicesLogger.error({
|
|
124
|
+
serviceName: service.name,
|
|
125
|
+
err: error,
|
|
126
|
+
}, 'Failed to shutdown service');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
servicesLogger.info('All services shutdown complete');
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get the number of registered services
|
|
133
|
+
*
|
|
134
|
+
* @returns The count of registered services
|
|
135
|
+
*/
|
|
136
|
+
get size() {
|
|
137
|
+
return this.services.size;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Check if a service is registered
|
|
141
|
+
*
|
|
142
|
+
* @param name - The name of the service to check
|
|
143
|
+
* @returns True if the service is registered
|
|
144
|
+
*/
|
|
145
|
+
has(name) {
|
|
146
|
+
return this.services.has(name);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get a registered service by name
|
|
150
|
+
*
|
|
151
|
+
* @param name - The name of the service to get
|
|
152
|
+
* @returns The service if registered, undefined otherwise
|
|
153
|
+
*/
|
|
154
|
+
get(name) {
|
|
155
|
+
return this.services.get(name);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get all registered service names
|
|
159
|
+
*
|
|
160
|
+
* @returns Array of registered service names
|
|
161
|
+
*/
|
|
162
|
+
getServiceNames() {
|
|
163
|
+
return Array.from(this.services.keys());
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=service-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-registry.js","sourceRoot":"","sources":["../../src/services/service-registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IAClB,QAAQ,GAAmC,IAAI,GAAG,EAAE,CAAC;IAE7D;;;;;OAKG;IACH,QAAQ,CAAC,OAA0B;QACjC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACpC,cAAc,CAAC,IAAI,CACjB,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,EAC7B,6DAA6D,CAC9D,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACzC,cAAc,CAAC,IAAI,CACjB;YACE,WAAW,EAAE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,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC7C,IAAI,CAAC;gBACH,cAAc,CAAC,KAAK,CAClB,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,EAC7B,uBAAuB,CACxB,CAAC;gBAEF,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;gBAEzB,cAAc,CAAC,IAAI,CACjB,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,EAC7B,+BAA+B,CAChC,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,kEAAkE;gBAClE,cAAc,CAAC,KAAK,CAClB;oBACE,WAAW,EAAE,OAAO,CAAC,IAAI;oBACzB,GAAG,EAAE,KAAK;iBACX,EACD,4BAA4B,CAC7B,CAAC;YACJ,CAAC;QACH,CAAC;QAED,cAAc,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IACxD,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,eAAe;QACb,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config Tools Module
|
|
3
|
+
*
|
|
4
|
+
* Exports config-related tool handlers for reuse between
|
|
5
|
+
* index.ts (stdio transport) and mcp-handler.ts (HTTP transport).
|
|
6
|
+
*/
|
|
7
|
+
export type { ReloadContext, ReloadConfigInput } from './reload-handler.js';
|
|
8
|
+
export { handleReloadConfig } from './reload-handler.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/config/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/config/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|