@contextvm/sdk 0.1.29 → 0.1.30-rc.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/README.md +71 -0
- package/dist/esm/core/utils/logger.d.ts +14 -1
- package/dist/esm/core/utils/logger.d.ts.map +1 -1
- package/dist/esm/core/utils/logger.js +128 -35
- package/dist/esm/core/utils/logger.js.map +1 -1
- package/dist/esm/relay/simple-relay-pool.d.ts.map +1 -1
- package/dist/esm/relay/simple-relay-pool.js.map +1 -1
- package/dist/esm/transport/base-nostr-transport.d.ts.map +1 -1
- package/dist/esm/transport/base-nostr-transport.js +160 -37
- package/dist/esm/transport/base-nostr-transport.js.map +1 -1
- package/dist/esm/transport/nostr-client-transport.d.ts.map +1 -1
- package/dist/esm/transport/nostr-client-transport.js +191 -60
- package/dist/esm/transport/nostr-client-transport.js.map +1 -1
- package/dist/esm/transport/nostr-server-transport.d.ts +1 -0
- package/dist/esm/transport/nostr-server-transport.d.ts.map +1 -1
- package/dist/esm/transport/nostr-server-transport.js +264 -129
- package/dist/esm/transport/nostr-server-transport.js.map +1 -1
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -29,6 +29,77 @@ npm install @contextvm/sdk
|
|
|
29
29
|
|
|
30
30
|
Visit the [ContextVM documentation](https://contextvm.org) for information on how to use ContextVM.
|
|
31
31
|
|
|
32
|
+
### Logging
|
|
33
|
+
|
|
34
|
+
The SDK uses Pino for high-performance logging with structured JSON output. By default, logs are written to stderr to comply with the MCP protocol expectations.
|
|
35
|
+
|
|
36
|
+
#### Basic Usage
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { createLogger } from '@contextvm/sdk/core';
|
|
40
|
+
|
|
41
|
+
// Create a logger for your module
|
|
42
|
+
const logger = createLogger('my-module');
|
|
43
|
+
|
|
44
|
+
logger.info('Application started');
|
|
45
|
+
logger.error('An error occurred', { error: 'details' });
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### Configuration Options
|
|
49
|
+
|
|
50
|
+
You can configure the logger with various options:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { createLogger, LoggerConfig } from '@contextvm/sdk/core';
|
|
54
|
+
|
|
55
|
+
const config: LoggerConfig = {
|
|
56
|
+
level: 'debug', // Minimum log level (debug, info, warn, error)
|
|
57
|
+
file: 'app.log', // Optional: log to a file instead of stderr
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const logger = createLogger('my-module', 'info', config);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Note:** Pretty printing is automatically enabled when logs are written to stderr/stdout (not to a file) for better readability during development.
|
|
64
|
+
|
|
65
|
+
#### Environment Variables
|
|
66
|
+
|
|
67
|
+
The logger respects the following environment variables:
|
|
68
|
+
|
|
69
|
+
- `LOG_LEVEL`: Sets the minimum log level (default: 'info')
|
|
70
|
+
- `LOG_DESTINATION`: Sets where logs are written - 'stderr' (default), 'stdout', or 'file'
|
|
71
|
+
- `LOG_FILE`: File path when `LOG_DESTINATION` is set to 'file'
|
|
72
|
+
- `LOG_ENABLED`: Enable/disable logging entirely - 'true' (default) or 'false'
|
|
73
|
+
|
|
74
|
+
#### Environment-based Configuration Examples
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Log to stderr with pretty printing (default)
|
|
78
|
+
LOG_LEVEL=info node app.js
|
|
79
|
+
|
|
80
|
+
# Log to stdout with pretty printing
|
|
81
|
+
LOG_DESTINATION=stdout node app.js
|
|
82
|
+
|
|
83
|
+
# Log to a file (pretty printing automatically disabled for file output)
|
|
84
|
+
LOG_DESTINATION=file LOG_FILE=./logs/app.log node app.js
|
|
85
|
+
|
|
86
|
+
# Completely disable logging
|
|
87
|
+
LOG_ENABLED=false node app.js
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Module-specific Loggers
|
|
91
|
+
|
|
92
|
+
Create child loggers for different modules to add context:
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const baseLogger = createLogger('my-app');
|
|
96
|
+
const authLogger = baseLogger.withModule('auth');
|
|
97
|
+
const dbLogger = baseLogger.withModule('database');
|
|
98
|
+
|
|
99
|
+
authLogger.info('User login attempt');
|
|
100
|
+
dbLogger.debug('Query executed', { query: 'SELECT * FROM users' });
|
|
101
|
+
```
|
|
102
|
+
|
|
32
103
|
## Development
|
|
33
104
|
|
|
34
105
|
This project requires [Bun](https://bun.sh/) (version 1.2.0 or higher).
|
|
@@ -13,10 +13,23 @@ export interface Logger {
|
|
|
13
13
|
error(message: string, data?: unknown): void;
|
|
14
14
|
withModule(newModule: string): Logger;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Configuration options for the logger
|
|
18
|
+
*/
|
|
19
|
+
export interface LoggerConfig {
|
|
20
|
+
/** Minimum log level to output */
|
|
21
|
+
level?: LogLevel;
|
|
22
|
+
/** Optional file path to write logs to. If not specified, logs go to stderr with pretty printing */
|
|
23
|
+
file?: string;
|
|
24
|
+
}
|
|
16
25
|
/**
|
|
17
26
|
* Creates a logger for the specified module with configurable log level
|
|
27
|
+
* @param module - The module name for log context
|
|
28
|
+
* @param minLevel - Minimum log level (default: 'info')
|
|
29
|
+
* @param config - Optional logger configuration
|
|
30
|
+
* @returns Logger instance with module context
|
|
18
31
|
*/
|
|
19
|
-
export declare function createLogger(module: string, minLevel?: LogLevel): Logger;
|
|
32
|
+
export declare function createLogger(module: string, minLevel?: LogLevel, config?: LoggerConfig): Logger;
|
|
20
33
|
/**
|
|
21
34
|
* Default logger instance for the application
|
|
22
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/logger.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,QAAQ,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7C,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,kCAAkC;IAClC,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,oGAAoG;IACpG,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAyGD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,QAAiB,EAC3B,MAAM,GAAE,YAAiB,GACxB,MAAM,CA2CR;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,QAAyD,CAAC"}
|
|
@@ -1,42 +1,134 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
warn: 2,
|
|
5
|
-
error: 3,
|
|
6
|
-
};
|
|
1
|
+
import pino from 'pino';
|
|
2
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
3
|
+
import { dirname } from 'path';
|
|
7
4
|
/**
|
|
8
|
-
*
|
|
5
|
+
* Get logger configuration from environment variables
|
|
6
|
+
* @returns Environment-based logger configuration
|
|
9
7
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return;
|
|
25
|
-
const entry = {
|
|
26
|
-
level,
|
|
27
|
-
timestamp: new Date().toISOString(),
|
|
28
|
-
module,
|
|
29
|
-
message,
|
|
30
|
-
data,
|
|
31
|
-
};
|
|
32
|
-
console.error(formatMessage(entry));
|
|
8
|
+
function getEnvLoggerConfig() {
|
|
9
|
+
// Log level from LOG_LEVEL env var
|
|
10
|
+
const level = getLogLevelFromEnv() || 'info';
|
|
11
|
+
// Destination from LOG_DESTINATION env var (stderr, stdout, file)
|
|
12
|
+
const destination = process.env.LOG_DESTINATION || 'stderr';
|
|
13
|
+
// File path from LOG_FILE env var when destination is 'file'
|
|
14
|
+
const filePath = process.env.LOG_FILE;
|
|
15
|
+
// Enable/disable logging from LOG_ENABLED env var (default: true)
|
|
16
|
+
const enabled = process.env.LOG_ENABLED !== 'false';
|
|
17
|
+
return {
|
|
18
|
+
level,
|
|
19
|
+
destination,
|
|
20
|
+
filePath,
|
|
21
|
+
enabled,
|
|
33
22
|
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a Pino logger instance with the specified configuration
|
|
26
|
+
* @param config - Logger configuration options
|
|
27
|
+
* @returns Configured Pino logger instance
|
|
28
|
+
*/
|
|
29
|
+
function createPinoLogger(config = {}) {
|
|
30
|
+
const envConfig = getEnvLoggerConfig();
|
|
31
|
+
// If logging is disabled, return a silent logger
|
|
32
|
+
if (!envConfig.enabled) {
|
|
33
|
+
return pino({ level: 'silent' });
|
|
34
|
+
}
|
|
35
|
+
// Use explicit config or fall back to environment config
|
|
36
|
+
const logLevel = config.level || envConfig.level;
|
|
37
|
+
const destination = config.file ? 'file' : envConfig.destination;
|
|
38
|
+
const filePath = config.file || envConfig.filePath;
|
|
39
|
+
// Use pretty printing when NOT logging to a file
|
|
40
|
+
const usePrettyPrint = !filePath;
|
|
41
|
+
// Configure transport for pretty printing (only when not logging to file)
|
|
42
|
+
const transport = usePrettyPrint
|
|
43
|
+
? {
|
|
44
|
+
target: 'pino-pretty',
|
|
45
|
+
options: {
|
|
46
|
+
colorize: true,
|
|
47
|
+
ignore: 'pid,hostname',
|
|
48
|
+
translateTime: 'yyyy-mm-dd HH:MM:ss',
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
: undefined;
|
|
52
|
+
// Determine destination based on configuration
|
|
53
|
+
let pinoDestination;
|
|
54
|
+
if (destination === 'file' && filePath) {
|
|
55
|
+
// If file logging is enabled, ensure directory exists and use file destination
|
|
56
|
+
const dir = dirname(filePath);
|
|
57
|
+
if (!existsSync(dir)) {
|
|
58
|
+
mkdirSync(dir, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
pinoDestination = pino.destination({
|
|
61
|
+
dest: filePath,
|
|
62
|
+
minLength: 1,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else if (destination === 'stdout') {
|
|
66
|
+
// Use stdout
|
|
67
|
+
pinoDestination = pino.destination({ dest: 1 }); // 1 is stdout
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// Default to stderr for MCP protocol compliance
|
|
71
|
+
pinoDestination = pino.destination({ dest: 2 }); // 2 is stderr
|
|
72
|
+
}
|
|
73
|
+
return pino({
|
|
74
|
+
level: logLevel,
|
|
75
|
+
transport,
|
|
76
|
+
base: {
|
|
77
|
+
env: process.env.NODE_ENV || 'unknown',
|
|
78
|
+
version: process.env.npm_package_version || '0.0.0',
|
|
79
|
+
},
|
|
80
|
+
timestamp: pino.stdTimeFunctions.isoTime,
|
|
81
|
+
}, pinoDestination);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a logger for the specified module with configurable log level
|
|
85
|
+
* @param module - The module name for log context
|
|
86
|
+
* @param minLevel - Minimum log level (default: 'info')
|
|
87
|
+
* @param config - Optional logger configuration
|
|
88
|
+
* @returns Logger instance with module context
|
|
89
|
+
*/
|
|
90
|
+
export function createLogger(module, minLevel = 'info', config = {}) {
|
|
91
|
+
// Create the base Pino logger
|
|
92
|
+
const pinoLogger = createPinoLogger({
|
|
93
|
+
...config,
|
|
94
|
+
level: minLevel,
|
|
95
|
+
});
|
|
96
|
+
// Create a child logger with module context
|
|
97
|
+
const moduleLogger = pinoLogger.child({ module });
|
|
34
98
|
return {
|
|
35
|
-
debug: (message, data) =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
99
|
+
debug: (message, data) => {
|
|
100
|
+
if (data) {
|
|
101
|
+
moduleLogger.debug(data, message);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
moduleLogger.debug(message);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
info: (message, data) => {
|
|
108
|
+
if (data) {
|
|
109
|
+
moduleLogger.info(data, message);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
moduleLogger.info(message);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
warn: (message, data) => {
|
|
116
|
+
if (data) {
|
|
117
|
+
moduleLogger.warn(data, message);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
moduleLogger.warn(message);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
error: (message, data) => {
|
|
124
|
+
if (data) {
|
|
125
|
+
moduleLogger.error(data, message);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
moduleLogger.error(message);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
withModule: (newModule) => createLogger(newModule, minLevel, config),
|
|
40
132
|
};
|
|
41
133
|
}
|
|
42
134
|
/**
|
|
@@ -45,6 +137,7 @@ export function createLogger(module, minLevel = 'info') {
|
|
|
45
137
|
export const logger = createLogger('ctxvm', getLogLevelFromEnv() || 'error');
|
|
46
138
|
/**
|
|
47
139
|
* Get log level from environment variables, handling both Node.js and browser environments
|
|
140
|
+
* @returns The log level from environment or undefined
|
|
48
141
|
*/
|
|
49
142
|
function getLogLevelFromEnv() {
|
|
50
143
|
if (typeof process !== 'undefined' && process.env && process.env.LOG_LEVEL) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../src/core/utils/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../src/core/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAA8B,MAAM,MAAM,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAwC/B;;;GAGG;AACH,SAAS,kBAAkB;IACzB,mCAAmC;IACnC,MAAM,KAAK,GAAG,kBAAkB,EAAE,IAAI,MAAM,CAAC;IAE7C,kEAAkE;IAClE,MAAM,WAAW,GACd,OAAO,CAAC,GAAG,CAAC,eAAgD,IAAI,QAAQ,CAAC;IAE5E,6DAA6D;IAC7D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IAEtC,kEAAkE;IAClE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,OAAO,CAAC;IAEpD,OAAO;QACL,KAAK;QACL,WAAW;QACX,QAAQ;QACR,OAAO;KACR,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,SAAuB,EAAE;IACjD,MAAM,SAAS,GAAG,kBAAkB,EAAE,CAAC;IAEvC,iDAAiD;IACjD,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,y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AAO,CAAC,KAAiB;QAC7B,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,KAAK,CAAC,SAAS,CACb,OAAiB,EACjB,OAAoC,EACpC,MAAmB;QAEnB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CACpC,IAAI,CAAC,mBAAmB,EACxB,OAAO,CAAC,CAAC,CAAC,EACV;YACE,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,MAAM;SACf,CACF,CAAC;QACF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,WAAW;QACT,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,WAAC,OAAA,MAAA,GAAG,CAAC,MAAM,0CAAE,KAAK,EAAE,CAAA,EAAA,CAAC,CAAC;QACzD,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-nostr-transport.d.ts","sourceRoot":"","sources":["../../../src/transport/base-nostr-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EACL,cAAc,EACd,WAAW,EACX,YAAY,EACb,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"base-nostr-transport.d.ts","sourceRoot":"","sources":["../../../src/transport/base-nostr-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,UA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AAE,MAAM,EAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,EACzB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,MAAM,CAAC;IAyDlB;;OAEG;IACH,SAAS,CAAC,yBAAyB,CACjC,YAAY,EAAE,MAAM,EACpB,iBAAiB,GAAE,OAAO,CAAC,MAAM,CAAM,GACtC,MAAM,EAAE;IAWX;;OAEG;IACH,SAAS,CAAC,mBAAmB,CAAC,eAAe,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAK1E;;OAEG;IACH,SAAS,CAAC,kBAAkB,CAC1B,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,GACtB,UAAU,CAAC,MAAM,CAAC;CAOtB"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { EncryptionMode, } from '../core/interfaces.js';
|
|
2
2
|
import { CTXVM_MESSAGES_KIND, GIFT_WRAP_KIND, mcpToNostrEvent, NOSTR_TAGS, nostrEventToMcpMessage, encryptMessage, SERVER_ANNOUNCEMENT_KIND, TOOLS_LIST_KIND, RESOURCES_LIST_KIND, RESOURCETEMPLATES_LIST_KIND, PROMPTS_LIST_KIND, } from '../core/index.js';
|
|
3
3
|
import { validateMessage, validateMessageSize } from '../core/utils/utils.js';
|
|
4
|
+
import { createLogger } from '../core/utils/logger.js';
|
|
5
|
+
const logger = createLogger('base-nostr-transport');
|
|
4
6
|
/**
|
|
5
7
|
* Base class for Nostr-based transports that provides common functionality
|
|
6
8
|
* for managing Nostr connections, event conversion, and message handling.
|
|
@@ -20,8 +22,18 @@ export class BaseNostrTransport {
|
|
|
20
22
|
if (this.isConnected) {
|
|
21
23
|
return;
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
try {
|
|
26
|
+
await this.relayHandler.connect();
|
|
27
|
+
this.isConnected = true;
|
|
28
|
+
logger.info('Connected to Nostr relay network');
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
logger.error('Failed to connect to Nostr relay network', {
|
|
32
|
+
error: error instanceof Error ? error.message : String(error),
|
|
33
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
34
|
+
});
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
25
37
|
}
|
|
26
38
|
/**
|
|
27
39
|
* Disconnects from the Nostr relay network.
|
|
@@ -30,20 +42,64 @@ export class BaseNostrTransport {
|
|
|
30
42
|
if (!this.isConnected) {
|
|
31
43
|
return;
|
|
32
44
|
}
|
|
33
|
-
|
|
34
|
-
|
|
45
|
+
try {
|
|
46
|
+
await this.relayHandler.disconnect();
|
|
47
|
+
this.isConnected = false;
|
|
48
|
+
logger.info('Disconnected from Nostr relay network');
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
logger.error('Failed to disconnect from Nostr relay network', {
|
|
52
|
+
error: error instanceof Error ? error.message : String(error),
|
|
53
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
54
|
+
});
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
35
57
|
}
|
|
36
58
|
/**
|
|
37
59
|
* Gets the public key from the signer.
|
|
38
60
|
*/
|
|
39
61
|
async getPublicKey() {
|
|
40
|
-
|
|
62
|
+
try {
|
|
63
|
+
return await this.signer.getPublicKey();
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
logger.error('Failed to get public key from signer', {
|
|
67
|
+
error: error instanceof Error ? error.message : String(error),
|
|
68
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
69
|
+
});
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
41
72
|
}
|
|
42
73
|
/**
|
|
43
74
|
* Sets up a subscription to listen for Nostr events.
|
|
44
75
|
*/
|
|
45
76
|
async subscribe(filters, onEvent) {
|
|
46
|
-
|
|
77
|
+
try {
|
|
78
|
+
await this.relayHandler.subscribe(filters, async (event) => {
|
|
79
|
+
try {
|
|
80
|
+
await onEvent(event);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
logger.error('Error in subscription event handler', {
|
|
84
|
+
error: error instanceof Error ? error.message : String(error),
|
|
85
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
86
|
+
eventId: event.id,
|
|
87
|
+
eventKind: event.kind,
|
|
88
|
+
});
|
|
89
|
+
// Re-throw to allow the relay handler to handle it
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
logger.debug('Subscribed to Nostr events', { filters });
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
logger.error('Failed to subscribe to Nostr events', {
|
|
97
|
+
error: error instanceof Error ? error.message : String(error),
|
|
98
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
99
|
+
filters,
|
|
100
|
+
});
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
47
103
|
}
|
|
48
104
|
/**
|
|
49
105
|
* Validates and converts a Nostr event to an MCP message.
|
|
@@ -52,20 +108,39 @@ export class BaseNostrTransport {
|
|
|
52
108
|
try {
|
|
53
109
|
const message = nostrEventToMcpMessage(event);
|
|
54
110
|
if (!message) {
|
|
111
|
+
logger.debug('Failed to convert Nostr event to MCP message - null result', {
|
|
112
|
+
eventId: event.id,
|
|
113
|
+
pubkey: event.pubkey,
|
|
114
|
+
});
|
|
55
115
|
return null;
|
|
56
116
|
}
|
|
57
117
|
// Validate message structure
|
|
58
118
|
const validatedMessage = validateMessage(message);
|
|
59
119
|
if (!validatedMessage) {
|
|
120
|
+
logger.warn('Failed to validate MCP message structure', {
|
|
121
|
+
eventId: event.id,
|
|
122
|
+
pubkey: event.pubkey,
|
|
123
|
+
});
|
|
60
124
|
return null;
|
|
61
125
|
}
|
|
62
126
|
// Validate message size
|
|
63
127
|
if (!validateMessageSize(event.content)) {
|
|
128
|
+
logger.warn('MCP message size validation failed', {
|
|
129
|
+
eventId: event.id,
|
|
130
|
+
pubkey: event.pubkey,
|
|
131
|
+
contentSize: event.content.length,
|
|
132
|
+
});
|
|
64
133
|
return null;
|
|
65
134
|
}
|
|
66
135
|
return validatedMessage;
|
|
67
136
|
}
|
|
68
|
-
catch (
|
|
137
|
+
catch (error) {
|
|
138
|
+
logger.error('Error converting Nostr event to MCP message', {
|
|
139
|
+
error: error instanceof Error ? error.message : String(error),
|
|
140
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
141
|
+
eventId: event.id,
|
|
142
|
+
pubkey: event.pubkey,
|
|
143
|
+
});
|
|
69
144
|
return null;
|
|
70
145
|
}
|
|
71
146
|
}
|
|
@@ -73,51 +148,99 @@ export class BaseNostrTransport {
|
|
|
73
148
|
* Converts an MCP message to a Nostr event and signs it.
|
|
74
149
|
*/
|
|
75
150
|
async createSignedNostrEvent(message, kind, tags) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
151
|
+
try {
|
|
152
|
+
const pubkey = await this.getPublicKey();
|
|
153
|
+
const unsignedEvent = mcpToNostrEvent(message, pubkey, kind, tags);
|
|
154
|
+
return await this.signer.signEvent(unsignedEvent);
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
logger.error('Failed to create signed Nostr event', {
|
|
158
|
+
error: error instanceof Error ? error.message : String(error),
|
|
159
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
160
|
+
kind,
|
|
161
|
+
hasTags: !!tags,
|
|
162
|
+
});
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
79
165
|
}
|
|
80
166
|
/**
|
|
81
167
|
* Publishes a signed Nostr event to the relay network.
|
|
82
168
|
*/
|
|
83
169
|
async publishEvent(event) {
|
|
84
|
-
|
|
170
|
+
try {
|
|
171
|
+
await this.relayHandler.publish(event);
|
|
172
|
+
logger.debug('Published Nostr event', {
|
|
173
|
+
eventId: event.id,
|
|
174
|
+
kind: event.kind,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
logger.error('Failed to publish Nostr event', {
|
|
179
|
+
error: error instanceof Error ? error.message : String(error),
|
|
180
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
181
|
+
eventId: event.id,
|
|
182
|
+
kind: event.kind,
|
|
183
|
+
});
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
85
186
|
}
|
|
86
187
|
/**
|
|
87
188
|
* Creates and publishes a Nostr event for an MCP message.
|
|
88
189
|
*/
|
|
89
190
|
async sendMcpMessage(message, recipientPublicKey, kind, tags, isEncrypted) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
if (this.encryptionMode === EncryptionMode.OPTIONAL) {
|
|
103
|
-
shouldEncrypt = isEncrypted !== null && isEncrypted !== void 0 ? isEncrypted : true;
|
|
104
|
-
}
|
|
105
|
-
else if (this.encryptionMode === EncryptionMode.DISABLED) {
|
|
191
|
+
try {
|
|
192
|
+
const unencryptedKinds = [
|
|
193
|
+
SERVER_ANNOUNCEMENT_KIND,
|
|
194
|
+
TOOLS_LIST_KIND,
|
|
195
|
+
RESOURCES_LIST_KIND,
|
|
196
|
+
RESOURCETEMPLATES_LIST_KIND,
|
|
197
|
+
PROMPTS_LIST_KIND,
|
|
198
|
+
];
|
|
199
|
+
let shouldEncrypt = true;
|
|
200
|
+
if (unencryptedKinds.includes(kind)) {
|
|
106
201
|
shouldEncrypt = false;
|
|
107
202
|
}
|
|
108
|
-
else
|
|
109
|
-
|
|
203
|
+
else {
|
|
204
|
+
if (this.encryptionMode === EncryptionMode.OPTIONAL) {
|
|
205
|
+
shouldEncrypt = isEncrypted !== null && isEncrypted !== void 0 ? isEncrypted : true;
|
|
206
|
+
}
|
|
207
|
+
else if (this.encryptionMode === EncryptionMode.DISABLED) {
|
|
208
|
+
shouldEncrypt = false;
|
|
209
|
+
}
|
|
210
|
+
else if (this.encryptionMode === EncryptionMode.REQUIRED) {
|
|
211
|
+
shouldEncrypt = true;
|
|
212
|
+
}
|
|
110
213
|
}
|
|
214
|
+
const event = await this.createSignedNostrEvent(message, kind, tags);
|
|
215
|
+
if (shouldEncrypt) {
|
|
216
|
+
const encryptedEvent = encryptMessage(JSON.stringify(event), recipientPublicKey);
|
|
217
|
+
await this.publishEvent(encryptedEvent);
|
|
218
|
+
logger.debug('Sent encrypted MCP message', {
|
|
219
|
+
eventId: event.id,
|
|
220
|
+
kind,
|
|
221
|
+
recipient: recipientPublicKey,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
await this.publishEvent(event);
|
|
226
|
+
logger.debug('Sent unencrypted MCP message', {
|
|
227
|
+
eventId: event.id,
|
|
228
|
+
kind,
|
|
229
|
+
recipient: recipientPublicKey,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return event.id;
|
|
111
233
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
234
|
+
catch (error) {
|
|
235
|
+
logger.error('Failed to send MCP message', {
|
|
236
|
+
error: error instanceof Error ? error.message : String(error),
|
|
237
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
238
|
+
kind,
|
|
239
|
+
recipient: recipientPublicKey,
|
|
240
|
+
encryptionMode: this.encryptionMode,
|
|
241
|
+
});
|
|
242
|
+
throw error;
|
|
119
243
|
}
|
|
120
|
-
return event.id;
|
|
121
244
|
}
|
|
122
245
|
/**
|
|
123
246
|
* Creates subscription filters for listening to messages targeting a specific pubkey.
|