@shin1ohno/sage 0.9.3 → 0.11.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.
- package/dist/cli/mcp-handler.d.ts.map +1 -1
- package/dist/cli/mcp-handler.js +154 -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 +109 -0
- package/dist/index.js.map +1 -1
- package/dist/oauth/index.d.ts +2 -0
- package/dist/oauth/index.d.ts.map +1 -1
- package/dist/oauth/index.js +4 -0
- package/dist/oauth/index.js.map +1 -1
- package/dist/oauth/oauth-callback-server.d.ts +100 -0
- package/dist/oauth/oauth-callback-server.d.ts.map +1 -0
- package/dist/oauth/oauth-callback-server.js +276 -0
- package/dist/oauth/oauth-callback-server.js.map +1 -0
- 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/oauth/authenticate-google.d.ts +54 -0
- package/dist/tools/oauth/authenticate-google.d.ts.map +1 -0
- package/dist/tools/oauth/authenticate-google.js +180 -0
- package/dist/tools/oauth/authenticate-google.js.map +1 -0
- package/dist/tools/oauth/index.d.ts +26 -0
- package/dist/tools/oauth/index.d.ts.map +1 -0
- package/dist/tools/oauth/index.js +9 -0
- package/dist/tools/oauth/index.js.map +1 -0
- 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/utils/browser-opener.d.ts +35 -0
- package/dist/utils/browser-opener.d.ts.map +1 -0
- package/dist/utils/browser-opener.js +71 -0
- package/dist/utils/browser-opener.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,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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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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config Reload Tool Handler
|
|
3
|
+
*
|
|
4
|
+
* Business logic for the reload_config MCP tool.
|
|
5
|
+
* Handles manual configuration reload requests.
|
|
6
|
+
*/
|
|
7
|
+
import type { ConfigReloadService } from '../../config/config-reload-service.js';
|
|
8
|
+
/**
|
|
9
|
+
* Context interface for reload handler
|
|
10
|
+
*/
|
|
11
|
+
export interface ReloadContext {
|
|
12
|
+
getConfigReloadService: () => ConfigReloadService | null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Input parameters for reload_config tool
|
|
16
|
+
*/
|
|
17
|
+
export interface ReloadConfigInput {
|
|
18
|
+
force?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Handle reload_config tool request
|
|
22
|
+
*
|
|
23
|
+
* Triggers a manual configuration reload without server restart.
|
|
24
|
+
*
|
|
25
|
+
* @param ctx - Context providing access to ConfigReloadService
|
|
26
|
+
* @param params - Optional parameters (force flag)
|
|
27
|
+
* @returns MCP tool response with reload result
|
|
28
|
+
*/
|
|
29
|
+
export declare function handleReloadConfig(ctx: ReloadContext, params?: ReloadConfigInput): Promise<{
|
|
30
|
+
content: {
|
|
31
|
+
type: "text";
|
|
32
|
+
text: string;
|
|
33
|
+
}[];
|
|
34
|
+
}>;
|
|
35
|
+
//# sourceMappingURL=reload-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reload-handler.d.ts","sourceRoot":"","sources":["../../../src/tools/config/reload-handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAMjF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,sBAAsB,EAAE,MAAM,mBAAmB,GAAG,IAAI,CAAC;CAC1D;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,aAAa,EAClB,MAAM,GAAE,iBAAsB;;;;;GAsD/B"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config Reload Tool Handler
|
|
3
|
+
*
|
|
4
|
+
* Business logic for the reload_config MCP tool.
|
|
5
|
+
* Handles manual configuration reload requests.
|
|
6
|
+
*/
|
|
7
|
+
import { createLogger } from '../../utils/logger.js';
|
|
8
|
+
import { createToolResponse, createErrorFromCatch } from '../registry.js';
|
|
9
|
+
const logger = createLogger('reload-handler');
|
|
10
|
+
/**
|
|
11
|
+
* Handle reload_config tool request
|
|
12
|
+
*
|
|
13
|
+
* Triggers a manual configuration reload without server restart.
|
|
14
|
+
*
|
|
15
|
+
* @param ctx - Context providing access to ConfigReloadService
|
|
16
|
+
* @param params - Optional parameters (force flag)
|
|
17
|
+
* @returns MCP tool response with reload result
|
|
18
|
+
*/
|
|
19
|
+
export async function handleReloadConfig(ctx, params = {}) {
|
|
20
|
+
logger.info({ force: params.force }, 'Reload config request received');
|
|
21
|
+
const configReloadService = ctx.getConfigReloadService();
|
|
22
|
+
if (!configReloadService) {
|
|
23
|
+
logger.warn('ConfigReloadService is not available');
|
|
24
|
+
return createToolResponse({
|
|
25
|
+
success: false,
|
|
26
|
+
error: 'Hot reload service is not initialized',
|
|
27
|
+
message: 'Hot reload機能が初期化されていません。サーバーを再起動してください。',
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const result = await configReloadService.reload();
|
|
32
|
+
logger.info({
|
|
33
|
+
success: result.success,
|
|
34
|
+
changedSections: result.changedSections,
|
|
35
|
+
reinitializedServices: result.reinitializedServices,
|
|
36
|
+
durationMs: result.durationMs,
|
|
37
|
+
}, 'Reload config completed');
|
|
38
|
+
if (result.success) {
|
|
39
|
+
return createToolResponse({
|
|
40
|
+
success: true,
|
|
41
|
+
changedSections: result.changedSections,
|
|
42
|
+
reinitializedServices: result.reinitializedServices,
|
|
43
|
+
timestamp: result.timestamp,
|
|
44
|
+
durationMs: result.durationMs,
|
|
45
|
+
message: result.changedSections.length > 0
|
|
46
|
+
? `設定をリロードしました。変更されたセクション: ${result.changedSections.join(', ')}`
|
|
47
|
+
: '設定をリロードしましたが、変更はありませんでした。',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return createToolResponse({
|
|
51
|
+
success: false,
|
|
52
|
+
error: result.error,
|
|
53
|
+
timestamp: result.timestamp,
|
|
54
|
+
durationMs: result.durationMs,
|
|
55
|
+
message: `設定のリロードに失敗しました: ${result.error}`,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
logger.error({ err: error }, 'Failed to reload configuration');
|
|
60
|
+
return createErrorFromCatch('設定のリロードに失敗しました', error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=reload-handler.js.map
|
|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AAqB;gBACnD,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,OAAO,EACL,MAAM,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;oBAC/B,CAAC,CAAC,2BAA2B,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAChE,CAAC,CAAC,2BAA2B;aAClC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,kBAAkB,CAAC;YACxB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,OAAO,EAAE,mBAAmB,MAAM,CAAC,KAAK,EAAE;SAC3C,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,gCAAgC,CAAC,CAAC;QAC/D,OAAO,oBAAoB,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;AACH,CAAC"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { UserConfig } from '../../types/index.js';
|
|
11
11
|
import type { NotionMCPService } from '../../integrations/notion-mcp.js';
|
|
12
|
+
import type { ConfigReloadService } from '../../config/config-reload-service.js';
|
|
12
13
|
/**
|
|
13
14
|
* Integration context containing shared state and services
|
|
14
15
|
*/
|
|
@@ -17,6 +18,7 @@ export interface IntegrationToolsContext {
|
|
|
17
18
|
setConfig: (config: UserConfig) => void;
|
|
18
19
|
getNotionService: () => NotionMCPService | null;
|
|
19
20
|
initializeServices: (config: UserConfig) => void;
|
|
21
|
+
getConfigReloadService?: () => ConfigReloadService | null;
|
|
20
22
|
}
|
|
21
23
|
export interface SyncToNotionInput {
|
|
22
24
|
taskTitle: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/tools/integrations/handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAY,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/tools/integrations/handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAY,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAQjF;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,UAAU,GAAG,IAAI,CAAC;IACnC,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,gBAAgB,EAAE,MAAM,gBAAgB,GAAG,IAAI,CAAC;IAChD,kBAAkB,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACjD,sBAAsB,CAAC,EAAE,MAAM,mBAAmB,GAAG,IAAI,CAAC;CAC3D;AAMD,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EACH,MAAM,GACN,UAAU,GACV,eAAe,GACf,cAAc,GACd,MAAM,GACN,aAAa,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAMD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,uBAAuB,EAC5B,IAAI,EAAE,iBAAiB;;;;;GAiHxB;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,uBAAuB,EAC5B,IAAI,EAAE,iBAAiB;;;;;GA6CxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../../src/tools/integrations/handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../../src/tools/integrations/handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAqC1E,+DAA+D;AAC/D,oBAAoB;AACpB,+DAA+D;AAE/D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,GAA4B,EAC5B,IAAuB;IAEvB,MAAM,EACJ,SAAS,EACT,WAAW,EACX,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,gBAAgB,GACjB,GAAG,IAAI,CAAC;IACT,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC;IAE/B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,kBAAkB,CAAC;YACxB,KAAK,EAAE,IAAI;YACX,OAAO,EACL,6CAA6C;SAChD,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACxC,OAAO,kBAAkB,CAAC;YACxB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;QAChE,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;YAC5B,OAAO,kBAAkB,CAAC;gBACxB,KAAK,EAAE,IAAI;gBACX,OAAO,EAAE,iBAAiB,gBAAgB,CAAC,KAAK,EAAE;gBAClD,aAAa,EAAE,gBAAgB,CAAC,aAAa;aAC9C,CAAC,CAAC;QACL,CAAC;QAED,0BAA0B;QAC1B,MAAM,aAAa,GAAG,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAEnE,0BAA0B;QAC1B,MAAM,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACvC,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QAE7B,iDAAiD;QACjD,IAAI,OAAO,KAAK,cAAc,EAAE,CAAC;YAC/B,GAAG,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;QACxC,CAAC;QAED,OAAO,kBAAkB,CAAC;YACxB,OAAO,EAAE,IAAI;YACb,OAAO;YACP,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;YACnC,OAAO,EAAE,cAAc,OAAO,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,oBAAoB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* authenticate_google Tool Handler
|
|
3
|
+
* Requirements: FR-1 (authenticate_google MCP Tool)
|
|
4
|
+
*
|
|
5
|
+
* Orchestrates the complete Google OAuth flow:
|
|
6
|
+
* 1. Check for existing tokens
|
|
7
|
+
* 2. Start callback server
|
|
8
|
+
* 3. Generate authorization URL
|
|
9
|
+
* 4. Open browser
|
|
10
|
+
* 5. Wait for callback
|
|
11
|
+
* 6. Exchange code for tokens
|
|
12
|
+
* 7. Store tokens
|
|
13
|
+
*/
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
import type { OAuthToolsContext } from './index.js';
|
|
16
|
+
/**
|
|
17
|
+
* Arguments for authenticate_google tool
|
|
18
|
+
*/
|
|
19
|
+
export declare const AuthenticateGoogleArgsSchema: z.ZodObject<{
|
|
20
|
+
/** Force re-authentication even if tokens exist */
|
|
21
|
+
force: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
22
|
+
/** Timeout in seconds (default: 300 = 5 minutes) */
|
|
23
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
timeout: number;
|
|
26
|
+
force: boolean;
|
|
27
|
+
}, {
|
|
28
|
+
timeout?: number | undefined;
|
|
29
|
+
force?: boolean | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export type AuthenticateGoogleArgs = z.infer<typeof AuthenticateGoogleArgsSchema>;
|
|
32
|
+
/**
|
|
33
|
+
* Result from authenticate_google tool
|
|
34
|
+
*/
|
|
35
|
+
export interface AuthenticateGoogleResult {
|
|
36
|
+
success: boolean;
|
|
37
|
+
message: string;
|
|
38
|
+
alreadyAuthenticated?: boolean;
|
|
39
|
+
expiresAt?: string;
|
|
40
|
+
scopes?: string[];
|
|
41
|
+
authorizationUrl?: string;
|
|
42
|
+
error?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Handle authenticate_google tool call
|
|
46
|
+
*
|
|
47
|
+
* Orchestrates the complete OAuth flow for Google Calendar authentication.
|
|
48
|
+
*
|
|
49
|
+
* @param args - Tool arguments
|
|
50
|
+
* @param context - OAuth tools context (unused, handler creates its own handler)
|
|
51
|
+
* @returns Authentication result
|
|
52
|
+
*/
|
|
53
|
+
export declare function handleAuthenticateGoogle(args: AuthenticateGoogleArgs, _context: OAuthToolsContext): Promise<AuthenticateGoogleResult>;
|
|
54
|
+
//# sourceMappingURL=authenticate-google.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate-google.d.ts","sourceRoot":"","sources":["../../../src/tools/oauth/authenticate-google.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,4BAA4B;IACvC,mDAAmD;;IAEnD,oDAAoD;;;;;;;;EAEpD,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,sBAAsB,EAC5B,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,CAAC,wBAAwB,CAAC,CAsKnC"}
|