openclaw-overlay-plugin 0.7.34 → 0.7.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +13 -2
  3. package/dist/src/scripts/config.d.ts +1 -1
  4. package/dist/src/scripts/config.js +1 -1
  5. package/index.ts +15 -2
  6. package/openclaw.plugin.json +2 -1
  7. package/package.json +1 -1
  8. package/src/scripts/config.ts +1 -1
  9. package/dist/cli-main.d.ts +0 -7
  10. package/dist/cli-main.js +0 -192
  11. package/dist/cli.d.ts +0 -8
  12. package/dist/cli.js +0 -14
  13. package/dist/core/config.d.ts +0 -11
  14. package/dist/core/config.js +0 -13
  15. package/dist/core/index.d.ts +0 -25
  16. package/dist/core/index.js +0 -26
  17. package/dist/core/payment.d.ts +0 -16
  18. package/dist/core/payment.js +0 -94
  19. package/dist/core/types.d.ts +0 -94
  20. package/dist/core/types.js +0 -4
  21. package/dist/core/verify.d.ts +0 -28
  22. package/dist/core/verify.js +0 -104
  23. package/dist/core/wallet.d.ts +0 -99
  24. package/dist/core/wallet.js +0 -219
  25. package/dist/scripts/baemail/commands.d.ts +0 -64
  26. package/dist/scripts/baemail/commands.js +0 -259
  27. package/dist/scripts/baemail/handler.d.ts +0 -36
  28. package/dist/scripts/baemail/handler.js +0 -284
  29. package/dist/scripts/baemail/index.d.ts +0 -5
  30. package/dist/scripts/baemail/index.js +0 -5
  31. package/dist/scripts/config.d.ts +0 -48
  32. package/dist/scripts/config.js +0 -68
  33. package/dist/scripts/index.d.ts +0 -7
  34. package/dist/scripts/index.js +0 -7
  35. package/dist/scripts/messaging/connect.d.ts +0 -8
  36. package/dist/scripts/messaging/connect.js +0 -114
  37. package/dist/scripts/messaging/handlers.d.ts +0 -21
  38. package/dist/scripts/messaging/handlers.js +0 -334
  39. package/dist/scripts/messaging/inbox.d.ts +0 -11
  40. package/dist/scripts/messaging/inbox.js +0 -51
  41. package/dist/scripts/messaging/index.d.ts +0 -8
  42. package/dist/scripts/messaging/index.js +0 -8
  43. package/dist/scripts/messaging/poll.d.ts +0 -7
  44. package/dist/scripts/messaging/poll.js +0 -52
  45. package/dist/scripts/messaging/send.d.ts +0 -7
  46. package/dist/scripts/messaging/send.js +0 -43
  47. package/dist/scripts/output.d.ts +0 -12
  48. package/dist/scripts/output.js +0 -19
  49. package/dist/scripts/overlay/discover.d.ts +0 -7
  50. package/dist/scripts/overlay/discover.js +0 -72
  51. package/dist/scripts/overlay/index.d.ts +0 -7
  52. package/dist/scripts/overlay/index.js +0 -7
  53. package/dist/scripts/overlay/registration.d.ts +0 -19
  54. package/dist/scripts/overlay/registration.js +0 -176
  55. package/dist/scripts/overlay/services.d.ts +0 -29
  56. package/dist/scripts/overlay/services.js +0 -167
  57. package/dist/scripts/overlay/transaction.d.ts +0 -42
  58. package/dist/scripts/overlay/transaction.js +0 -103
  59. package/dist/scripts/payment/build.d.ts +0 -24
  60. package/dist/scripts/payment/build.js +0 -54
  61. package/dist/scripts/payment/commands.d.ts +0 -15
  62. package/dist/scripts/payment/commands.js +0 -73
  63. package/dist/scripts/payment/index.d.ts +0 -6
  64. package/dist/scripts/payment/index.js +0 -6
  65. package/dist/scripts/payment/types.d.ts +0 -56
  66. package/dist/scripts/payment/types.js +0 -4
  67. package/dist/scripts/services/index.d.ts +0 -6
  68. package/dist/scripts/services/index.js +0 -6
  69. package/dist/scripts/services/queue.d.ts +0 -11
  70. package/dist/scripts/services/queue.js +0 -28
  71. package/dist/scripts/services/request.d.ts +0 -7
  72. package/dist/scripts/services/request.js +0 -82
  73. package/dist/scripts/services/respond.d.ts +0 -11
  74. package/dist/scripts/services/respond.js +0 -132
  75. package/dist/scripts/types.d.ts +0 -107
  76. package/dist/scripts/types.js +0 -4
  77. package/dist/scripts/utils/index.d.ts +0 -6
  78. package/dist/scripts/utils/index.js +0 -6
  79. package/dist/scripts/utils/merkle.d.ts +0 -12
  80. package/dist/scripts/utils/merkle.js +0 -47
  81. package/dist/scripts/utils/storage.d.ts +0 -66
  82. package/dist/scripts/utils/storage.js +0 -211
  83. package/dist/scripts/utils/woc.d.ts +0 -26
  84. package/dist/scripts/utils/woc.js +0 -91
  85. package/dist/scripts/wallet/balance.d.ts +0 -22
  86. package/dist/scripts/wallet/balance.js +0 -240
  87. package/dist/scripts/wallet/identity.d.ts +0 -70
  88. package/dist/scripts/wallet/identity.js +0 -151
  89. package/dist/scripts/wallet/index.d.ts +0 -6
  90. package/dist/scripts/wallet/index.js +0 -6
  91. package/dist/scripts/wallet/setup.d.ts +0 -15
  92. package/dist/scripts/wallet/setup.js +0 -105
  93. package/dist/scripts/x-verification/commands.d.ts +0 -27
  94. package/dist/scripts/x-verification/commands.js +0 -222
  95. package/dist/scripts/x-verification/index.d.ts +0 -4
  96. package/dist/scripts/x-verification/index.js +0 -4
  97. package/dist/services/built-in/api-proxy/index.d.ts +0 -6
  98. package/dist/services/built-in/api-proxy/index.js +0 -23
  99. package/dist/services/built-in/code-develop/index.d.ts +0 -6
  100. package/dist/services/built-in/code-develop/index.js +0 -23
  101. package/dist/services/built-in/code-review/index.d.ts +0 -10
  102. package/dist/services/built-in/code-review/index.js +0 -51
  103. package/dist/services/built-in/image-analysis/index.d.ts +0 -6
  104. package/dist/services/built-in/image-analysis/index.js +0 -33
  105. package/dist/services/built-in/memory-store/index.d.ts +0 -6
  106. package/dist/services/built-in/memory-store/index.js +0 -22
  107. package/dist/services/built-in/roulette/index.d.ts +0 -6
  108. package/dist/services/built-in/roulette/index.js +0 -27
  109. package/dist/services/built-in/summarize/index.d.ts +0 -6
  110. package/dist/services/built-in/summarize/index.js +0 -21
  111. package/dist/services/built-in/tell-joke/handler.d.ts +0 -7
  112. package/dist/services/built-in/tell-joke/handler.js +0 -122
  113. package/dist/services/built-in/tell-joke/index.d.ts +0 -9
  114. package/dist/services/built-in/tell-joke/index.js +0 -31
  115. package/dist/services/built-in/translate/index.d.ts +0 -6
  116. package/dist/services/built-in/translate/index.js +0 -21
  117. package/dist/services/built-in/web-research/index.d.ts +0 -9
  118. package/dist/services/built-in/web-research/index.js +0 -51
  119. package/dist/services/index.d.ts +0 -13
  120. package/dist/services/index.js +0 -14
  121. package/dist/services/loader.d.ts +0 -77
  122. package/dist/services/loader.js +0 -292
  123. package/dist/services/manager.d.ts +0 -86
  124. package/dist/services/manager.js +0 -255
  125. package/dist/services/registry.d.ts +0 -98
  126. package/dist/services/registry.js +0 -204
  127. package/dist/services/types.d.ts +0 -230
  128. package/dist/services/types.js +0 -30
  129. package/dist/test/cli.test.d.ts +0 -7
  130. package/dist/test/cli.test.js +0 -329
  131. package/dist/test/comprehensive-overlay.test.d.ts +0 -13
  132. package/dist/test/comprehensive-overlay.test.js +0 -593
  133. package/dist/test/key-derivation.test.d.ts +0 -12
  134. package/dist/test/key-derivation.test.js +0 -86
  135. package/dist/test/overlay-submit.test.d.ts +0 -10
  136. package/dist/test/overlay-submit.test.js +0 -460
  137. package/dist/test/request-response-flow.test.d.ts +0 -5
  138. package/dist/test/request-response-flow.test.js +0 -209
  139. package/dist/test/service-system.test.d.ts +0 -5
  140. package/dist/test/service-system.test.js +0 -190
  141. package/dist/test/utils/server-logic.d.ts +0 -98
  142. package/dist/test/utils/server-logic.js +0 -286
  143. package/dist/test/wallet.test.d.ts +0 -7
  144. package/dist/test/wallet.test.js +0 -146
@@ -1,31 +0,0 @@
1
- /**
2
- * Tell Joke service definition.
3
- *
4
- * A simple service that tells random jokes. This demonstrates
5
- * a basic service that works in both handler and agent modes.
6
- */
7
- import { ServiceCategory } from '../../types.js';
8
- import { tellJokeHandler } from './handler.js';
9
- const tellJokeService = {
10
- id: 'tell-joke',
11
- name: 'Random Joke',
12
- description: 'Get a random joke. Guaranteed to be at least mildly amusing.',
13
- defaultPrice: 5,
14
- category: ServiceCategory.ENTERTAINMENT,
15
- inputSchema: {
16
- type: 'object',
17
- properties: {
18
- topic: {
19
- type: 'string',
20
- description: 'Optional topic for the joke (e.g., "programming", "cats")'
21
- },
22
- style: {
23
- type: 'string',
24
- enum: ['dad', 'pun', 'tech', 'general'],
25
- description: 'Style of joke to tell'
26
- }
27
- }
28
- },
29
- handler: tellJokeHandler
30
- };
31
- export default tellJokeService;
@@ -1,6 +0,0 @@
1
- /**
2
- * Translation service definition.
3
- */
4
- import { ServiceDefinition } from '../../types.js';
5
- declare const translateService: ServiceDefinition;
6
- export default translateService;
@@ -1,21 +0,0 @@
1
- /**
2
- * Translation service definition.
3
- */
4
- import { ServiceCategory } from '../../types.js';
5
- const translateService = {
6
- id: 'translate',
7
- name: 'Translation',
8
- description: 'Translate text between 30+ languages. Accurate, context-aware translations.',
9
- defaultPrice: 20,
10
- category: ServiceCategory.UTILITY,
11
- inputSchema: {
12
- type: 'object',
13
- properties: {
14
- text: { type: 'string', description: 'Text to translate' },
15
- to: { type: 'string', description: 'Target language (e.g., "es", "french", "Japanese")' },
16
- from: { type: 'string', description: 'Source language (auto-detected if not provided)' }
17
- },
18
- required: ['text', 'to']
19
- }
20
- };
21
- export default translateService;
@@ -1,9 +0,0 @@
1
- /**
2
- * Web Research service definition.
3
- *
4
- * Research any topic using current web sources and return a synthesized
5
- * summary with cited sources. Agent-mode service leveraging web search.
6
- */
7
- import { ServiceDefinition } from '../../types.js';
8
- declare const webResearchService: ServiceDefinition;
9
- export default webResearchService;
@@ -1,51 +0,0 @@
1
- /**
2
- * Web Research service definition.
3
- *
4
- * Research any topic using current web sources and return a synthesized
5
- * summary with cited sources. Agent-mode service leveraging web search.
6
- */
7
- import { ServiceCategory } from '../../types.js';
8
- const webResearchService = {
9
- id: 'web-research',
10
- name: 'Web Research',
11
- description: 'Research any topic using current web sources. Returns a synthesized summary with cited sources.',
12
- defaultPrice: 50,
13
- category: ServiceCategory.RESEARCH,
14
- inputSchema: {
15
- type: 'object',
16
- properties: {
17
- query: {
18
- type: 'string',
19
- description: 'Research query or topic'
20
- },
21
- depth: {
22
- type: 'string',
23
- enum: ['quick', 'standard', 'comprehensive'],
24
- description: 'Research depth (default: standard)'
25
- },
26
- sources: {
27
- type: 'number',
28
- minimum: 3,
29
- maximum: 20,
30
- description: 'Number of sources to research (default: 5)'
31
- },
32
- focusAreas: {
33
- type: 'array',
34
- items: { type: 'string' },
35
- description: 'Specific aspects to focus on'
36
- },
37
- excludeDomains: {
38
- type: 'array',
39
- items: { type: 'string' },
40
- description: 'Domains to exclude from research'
41
- },
42
- timeframe: {
43
- type: 'string',
44
- enum: ['day', 'week', 'month', 'year', 'all'],
45
- description: 'How recent the information should be'
46
- }
47
- },
48
- required: ['query']
49
- }
50
- };
51
- export default webResearchService;
@@ -1,13 +0,0 @@
1
- /**
2
- * Service system main exports.
3
- *
4
- * This is the main entry point for the service system, providing
5
- * a clean interface for the rest of the application.
6
- */
7
- export * from './types.js';
8
- export * from './registry.js';
9
- export * from './loader.js';
10
- export * from './manager.js';
11
- export { serviceRegistry } from './registry.js';
12
- export { serviceLoader } from './loader.js';
13
- export { serviceManager, initializeServiceSystem, getServiceManager } from './manager.js';
@@ -1,14 +0,0 @@
1
- /**
2
- * Service system main exports.
3
- *
4
- * This is the main entry point for the service system, providing
5
- * a clean interface for the rest of the application.
6
- */
7
- export * from './types.js';
8
- export * from './registry.js';
9
- export * from './loader.js';
10
- export * from './manager.js';
11
- // Re-export the main instances for easy access
12
- export { serviceRegistry } from './registry.js';
13
- export { serviceLoader } from './loader.js';
14
- export { serviceManager, initializeServiceSystem, getServiceManager } from './manager.js';
@@ -1,77 +0,0 @@
1
- /**
2
- * Service loader implementation.
3
- *
4
- * This dynamically loads services from directories, supporting both
5
- * built-in services and custom user services.
6
- */
7
- import { ServiceDefinition, ServiceLoader } from './types.js';
8
- /**
9
- * Default service loader implementation.
10
- */
11
- export declare class DefaultServiceLoader implements ServiceLoader {
12
- private builtInDir;
13
- private customDir;
14
- constructor();
15
- /**
16
- * Load services from a directory.
17
- */
18
- loadFromDirectory(directory: string): Promise<ServiceDefinition[]>;
19
- /**
20
- * Load all built-in services.
21
- */
22
- loadBuiltInServices(): Promise<ServiceDefinition[]>;
23
- /**
24
- * Load custom user services.
25
- */
26
- loadCustomServices(): Promise<ServiceDefinition[]>;
27
- /**
28
- * Load all services (built-in + custom).
29
- */
30
- loadAllServices(): Promise<ServiceDefinition[]>;
31
- /**
32
- * Load a service definition from a directory.
33
- */
34
- private loadServiceFromDirectory;
35
- /**
36
- * Create a new custom service directory.
37
- */
38
- createCustomServiceDirectory(serviceId: string): string;
39
- /**
40
- * Create a basic service template.
41
- */
42
- createServiceTemplate(serviceId: string, options: {
43
- name: string;
44
- description: string;
45
- defaultPrice: number;
46
- category?: string;
47
- hasHandler?: boolean;
48
- }): void;
49
- /**
50
- * Generate service definition template.
51
- */
52
- private generateServiceTemplate;
53
- /**
54
- * Generate prompt template.
55
- */
56
- private generatePromptTemplate;
57
- /**
58
- * Generate handler template.
59
- */
60
- private generateHandlerTemplate;
61
- /**
62
- * Get the built-in services directory.
63
- */
64
- getBuiltInDirectory(): string;
65
- /**
66
- * Get the custom services directory.
67
- */
68
- getCustomDirectory(): string;
69
- /**
70
- * Check if a service directory exists.
71
- */
72
- serviceExists(serviceId: string, inCustom?: boolean): boolean;
73
- }
74
- /**
75
- * Global service loader instance.
76
- */
77
- export declare const serviceLoader: DefaultServiceLoader;
@@ -1,292 +0,0 @@
1
- /**
2
- * Service loader implementation.
3
- *
4
- * This dynamically loads services from directories, supporting both
5
- * built-in services and custom user services.
6
- */
7
- import fs from 'node:fs';
8
- import path from 'node:path';
9
- import { fileURLToPath } from 'node:url';
10
- const __filename = fileURLToPath(import.meta.url);
11
- const __dirname = path.dirname(__filename);
12
- /**
13
- * Default service loader implementation.
14
- */
15
- export class DefaultServiceLoader {
16
- builtInDir;
17
- customDir;
18
- constructor() {
19
- // Built-in services directory
20
- this.builtInDir = path.resolve(__dirname, 'built-in');
21
- // Custom services directory (in user's config dir)
22
- const homeDir = process.env.HOME || process.env.USERPROFILE || '';
23
- this.customDir = path.join(homeDir, '.openclaw', 'services');
24
- }
25
- /**
26
- * Load services from a directory.
27
- */
28
- async loadFromDirectory(directory) {
29
- if (!fs.existsSync(directory)) {
30
- return [];
31
- }
32
- const services = [];
33
- const entries = fs.readdirSync(directory, { withFileTypes: true });
34
- for (const entry of entries) {
35
- if (!entry.isDirectory()) {
36
- continue;
37
- }
38
- try {
39
- const serviceDefinition = await this.loadServiceFromDirectory(path.join(directory, entry.name));
40
- if (serviceDefinition) {
41
- services.push(serviceDefinition);
42
- }
43
- }
44
- catch (error) {
45
- console.warn(`Failed to load service from ${entry.name}:`, error);
46
- }
47
- }
48
- return services;
49
- }
50
- /**
51
- * Load all built-in services.
52
- */
53
- async loadBuiltInServices() {
54
- return this.loadFromDirectory(this.builtInDir);
55
- }
56
- /**
57
- * Load custom user services.
58
- */
59
- async loadCustomServices() {
60
- return this.loadFromDirectory(this.customDir);
61
- }
62
- /**
63
- * Load all services (built-in + custom).
64
- */
65
- async loadAllServices() {
66
- const [builtIn, custom] = await Promise.all([
67
- this.loadBuiltInServices(),
68
- this.loadCustomServices()
69
- ]);
70
- return [...builtIn, ...custom];
71
- }
72
- /**
73
- * Load a service definition from a directory.
74
- */
75
- async loadServiceFromDirectory(serviceDir) {
76
- const indexPath = path.join(serviceDir, 'index.ts');
77
- const jsIndexPath = path.join(serviceDir, 'index.js');
78
- const promptPath = path.join(serviceDir, 'prompt.md');
79
- // Check if index file exists (TypeScript or JavaScript)
80
- let modulePath;
81
- if (fs.existsSync(indexPath)) {
82
- modulePath = indexPath;
83
- }
84
- else if (fs.existsSync(jsIndexPath)) {
85
- modulePath = jsIndexPath;
86
- }
87
- else {
88
- throw new Error(`No index.ts or index.js found in ${serviceDir}`);
89
- }
90
- try {
91
- // Dynamic import the service module
92
- const serviceModule = await import(modulePath);
93
- const serviceDefinition = serviceModule.default || serviceModule;
94
- if (!serviceDefinition || typeof serviceDefinition !== 'object') {
95
- throw new Error('Service must export a default ServiceDefinition object');
96
- }
97
- // Validate required fields
98
- if (!serviceDefinition.id) {
99
- throw new Error('Service definition must have an id');
100
- }
101
- // Add prompt file path if it exists
102
- if (fs.existsSync(promptPath)) {
103
- serviceDefinition.promptFile = promptPath;
104
- }
105
- return serviceDefinition;
106
- }
107
- catch (error) {
108
- throw new Error(`Failed to import service from ${modulePath}: ${error}`);
109
- }
110
- }
111
- /**
112
- * Create a new custom service directory.
113
- */
114
- createCustomServiceDirectory(serviceId) {
115
- const serviceDir = path.join(this.customDir, serviceId);
116
- // Ensure custom services directory exists
117
- fs.mkdirSync(this.customDir, { recursive: true });
118
- // Create service directory
119
- if (fs.existsSync(serviceDir)) {
120
- throw new Error(`Service directory ${serviceId} already exists`);
121
- }
122
- fs.mkdirSync(serviceDir);
123
- return serviceDir;
124
- }
125
- /**
126
- * Create a basic service template.
127
- */
128
- createServiceTemplate(serviceId, options) {
129
- const serviceDir = this.createCustomServiceDirectory(serviceId);
130
- // Create index.ts
131
- const indexContent = this.generateServiceTemplate(serviceId, options);
132
- fs.writeFileSync(path.join(serviceDir, 'index.ts'), indexContent);
133
- // Create prompt.md
134
- const promptContent = this.generatePromptTemplate(serviceId, options);
135
- fs.writeFileSync(path.join(serviceDir, 'prompt.md'), promptContent);
136
- // Create handler.ts if requested
137
- if (options.hasHandler) {
138
- const handlerContent = this.generateHandlerTemplate(serviceId, options);
139
- fs.writeFileSync(path.join(serviceDir, 'handler.ts'), handlerContent);
140
- }
141
- }
142
- /**
143
- * Generate service definition template.
144
- */
145
- generateServiceTemplate(serviceId, options) {
146
- return `/**
147
- * ${options.name} service definition.
148
- */
149
-
150
- import { ServiceDefinition${options.hasHandler ? ', ServiceHandler' : ''} } from '../../types.js';
151
- ${options.hasHandler ? `import { ${serviceId.replace(/-/g, '')}Handler } from './handler.js';` : ''}
152
-
153
- const ${serviceId.replace(/-/g, '')}Service: ServiceDefinition = {
154
- id: '${serviceId}',
155
- name: '${options.name}',
156
- description: '${options.description}',
157
- defaultPrice: ${options.defaultPrice},${options.category ? `\n category: '${options.category}',` : ''}
158
- inputSchema: {
159
- type: 'object',
160
- properties: {
161
- // Define your input schema here
162
- query: {
163
- type: 'string',
164
- description: 'Query or input for the service'
165
- }
166
- },
167
- required: ['query']
168
- }${options.hasHandler ? `,\n handler: ${serviceId.replace(/-/g, '')}Handler` : ''}
169
- };
170
-
171
- export default ${serviceId.replace(/-/g, '')}Service;
172
- `;
173
- }
174
- /**
175
- * Generate prompt template.
176
- */
177
- generatePromptTemplate(serviceId, options) {
178
- return `# ${options.name} Service
179
-
180
- You are processing a request for the "${serviceId}" service.
181
-
182
- ## Service Description
183
- ${options.description}
184
-
185
- ## Input
186
- The user has provided the following input:
187
- \`\`\`json
188
- {{input}}
189
- \`\`\`
190
-
191
- ## Instructions
192
- Process the user's request and provide a helpful response based on the service description.
193
- Format your response as a structured result that can be easily parsed and used.
194
-
195
- ## Response Format
196
- Provide your response in this format:
197
- \`\`\`json
198
- {
199
- "result": "your processed result here",
200
- "metadata": {
201
- "processingTime": "time taken",
202
- "version": "1.0"
203
- }
204
- }
205
- \`\`\`
206
- `;
207
- }
208
- /**
209
- * Generate handler template.
210
- */
211
- generateHandlerTemplate(serviceId, options) {
212
- return `/**
213
- * ${options.name} service handler.
214
- */
215
-
216
- import { ServiceHandler, ValidationResult, ServiceContext, ServiceResult } from '../../types.js';
217
-
218
- export const ${serviceId.replace(/-/g, '')}Handler: ServiceHandler = {
219
- /**
220
- * Validate service input.
221
- */
222
- validate(input: any): ValidationResult {
223
- if (!input || typeof input !== 'object') {
224
- return { valid: false, error: 'Input must be an object' };
225
- }
226
-
227
- if (!input.query || typeof input.query !== 'string') {
228
- return { valid: false, error: 'Query must be a non-empty string' };
229
- }
230
-
231
- // Add more validation as needed
232
- return { valid: true, sanitized: input };
233
- },
234
-
235
- /**
236
- * Process the service request.
237
- */
238
- async process(input: any, context: ServiceContext): Promise<ServiceResult> {
239
- try {
240
- const startTime = Date.now();
241
-
242
- // Your service logic here
243
- const result = {
244
- query: input.query,
245
- response: 'This is a template response. Implement your logic here.',
246
- timestamp: new Date().toISOString()
247
- };
248
-
249
- const processingTime = Date.now() - startTime;
250
-
251
- return {
252
- success: true,
253
- data: result,
254
- metadata: {
255
- processingTime,
256
- version: '1.0'
257
- }
258
- };
259
- } catch (error) {
260
- return {
261
- success: false,
262
- error: error instanceof Error ? error.message : String(error)
263
- };
264
- }
265
- }
266
- };
267
- `;
268
- }
269
- /**
270
- * Get the built-in services directory.
271
- */
272
- getBuiltInDirectory() {
273
- return this.builtInDir;
274
- }
275
- /**
276
- * Get the custom services directory.
277
- */
278
- getCustomDirectory() {
279
- return this.customDir;
280
- }
281
- /**
282
- * Check if a service directory exists.
283
- */
284
- serviceExists(serviceId, inCustom = false) {
285
- const baseDir = inCustom ? this.customDir : this.builtInDir;
286
- return fs.existsSync(path.join(baseDir, serviceId));
287
- }
288
- }
289
- /**
290
- * Global service loader instance.
291
- */
292
- export const serviceLoader = new DefaultServiceLoader();
@@ -1,86 +0,0 @@
1
- /**
2
- * Service manager implementation.
3
- *
4
- * This orchestrates the service system, providing a high-level interface
5
- * for service execution while keeping payment and relay logic separate.
6
- */
7
- import { ServiceManager, ServiceDefinition, ServiceContext, ServiceResult, ValidationResult } from './types.js';
8
- import { DefaultServiceRegistry } from './registry.js';
9
- import { DefaultServiceLoader } from './loader.js';
10
- /**
11
- * Default service manager implementation.
12
- */
13
- export declare class DefaultServiceManager implements ServiceManager {
14
- readonly registry: DefaultServiceRegistry;
15
- readonly loader: DefaultServiceLoader;
16
- private initialized;
17
- constructor();
18
- /**
19
- * Initialize the service system.
20
- */
21
- initialize(): Promise<void>;
22
- /**
23
- * Execute a service request.
24
- */
25
- execute(serviceId: string, input: any, context: ServiceContext): Promise<ServiceResult>;
26
- /**
27
- * Validate service input.
28
- */
29
- validate(serviceId: string, input: any): ValidationResult;
30
- /**
31
- * Reload all services.
32
- */
33
- reload(): Promise<void>;
34
- /**
35
- * Get service for agent-mode processing.
36
- */
37
- getServiceForAgentMode(serviceId: string): {
38
- service: ServiceDefinition;
39
- promptFile?: string;
40
- } | null;
41
- /**
42
- * Check if service is available.
43
- */
44
- isServiceAvailable(serviceId: string): boolean;
45
- /**
46
- * Get service execution mode.
47
- */
48
- getServiceMode(serviceId: string): 'handler' | 'agent' | null;
49
- /**
50
- * Get all available services for discovery.
51
- */
52
- getAvailableServices(): Array<{
53
- id: string;
54
- name: string;
55
- description: string;
56
- defaultPrice: number;
57
- category?: string;
58
- mode: 'handler' | 'agent';
59
- }>;
60
- /**
61
- * Validate input against JSON schema.
62
- */
63
- private validateAgainstSchema;
64
- /**
65
- * Get service statistics.
66
- */
67
- getStatistics(): {
68
- totalServices: number;
69
- handlerServices: number;
70
- agentServices: number;
71
- servicesByCategory: Record<string, number>;
72
- };
73
- }
74
- /**
75
- * Global service manager instance.
76
- */
77
- export declare const serviceManager: DefaultServiceManager;
78
- /**
79
- * Initialize the service system.
80
- * This should be called once during application startup.
81
- */
82
- export declare function initializeServiceSystem(): Promise<void>;
83
- /**
84
- * Get service manager instance.
85
- */
86
- export declare function getServiceManager(): DefaultServiceManager;