keryx 0.21.4 → 0.21.6
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/classes/Connection.ts +5 -5
- package/classes/Logger.ts +9 -10
- package/initializers/mcp.ts +2 -2
- package/package.json +11 -15
- package/servers/web.ts +4 -5
- package/util/ansi.ts +14 -0
package/classes/Connection.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import colors from "colors";
|
|
2
1
|
import { randomUUID } from "crypto";
|
|
3
2
|
import { api, logger } from "../api";
|
|
4
3
|
import { config } from "../config";
|
|
5
4
|
import type { PubSubMessage } from "../initializers/pubsub";
|
|
6
5
|
import type { SessionData } from "../initializers/session";
|
|
7
6
|
import type { RateLimitInfo } from "../middleware/rateLimit";
|
|
7
|
+
import { ansi } from "../util/ansi";
|
|
8
8
|
import { isSecret } from "../util/zodMixins";
|
|
9
9
|
import type { Action, ActionParams } from "./Action";
|
|
10
10
|
import { LogFormat } from "./Logger";
|
|
@@ -380,20 +380,20 @@ function logAction(opts: {
|
|
|
380
380
|
logger.info(`action: ${opts.actionName}`, data);
|
|
381
381
|
} else {
|
|
382
382
|
const loggingParams = config.logger.colorize
|
|
383
|
-
?
|
|
383
|
+
? ansi.gray(JSON.stringify(opts.params))
|
|
384
384
|
: JSON.stringify(opts.params);
|
|
385
385
|
|
|
386
386
|
const statusMessage = `[ACTION:${opts.connectionType.toUpperCase()}:${opts.status}]`;
|
|
387
387
|
const messagePrefix = config.logger.colorize
|
|
388
388
|
? opts.status === "OK"
|
|
389
|
-
?
|
|
390
|
-
:
|
|
389
|
+
? ansi.bgBlue(statusMessage)
|
|
390
|
+
: ansi.bgMagenta(statusMessage)
|
|
391
391
|
: statusMessage;
|
|
392
392
|
|
|
393
393
|
const errorStack =
|
|
394
394
|
opts.error && opts.error.stack
|
|
395
395
|
? config.logger.colorize
|
|
396
|
-
? "\r\n" +
|
|
396
|
+
? "\r\n" + ansi.gray(opts.error.stack)
|
|
397
397
|
: "\r\n" + opts.error.stack
|
|
398
398
|
: "";
|
|
399
399
|
|
package/classes/Logger.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import colors from "colors";
|
|
2
|
-
|
|
3
1
|
import type { configLogger } from "../config/logger";
|
|
2
|
+
import { ansi } from "../util/ansi";
|
|
4
3
|
|
|
5
4
|
export enum LogLevel {
|
|
6
5
|
trace = "trace",
|
|
@@ -133,7 +132,7 @@ export class Logger {
|
|
|
133
132
|
private logText(level: LogLevel, message: string, data?: any) {
|
|
134
133
|
let timestamp = this.includeTimestamps ? `${new Date().toISOString()}` : "";
|
|
135
134
|
if (this.colorize && timestamp.length > 0) {
|
|
136
|
-
timestamp =
|
|
135
|
+
timestamp = ansi.gray(timestamp);
|
|
137
136
|
}
|
|
138
137
|
|
|
139
138
|
let formattedLevel = `[${level}]`;
|
|
@@ -146,7 +145,7 @@ export class Logger {
|
|
|
146
145
|
? JSON.stringify(data, null, this.jSONObjectParsePadding)
|
|
147
146
|
: "";
|
|
148
147
|
if (this.colorize && prettyObject.length > 0) {
|
|
149
|
-
prettyObject =
|
|
148
|
+
prettyObject = ansi.cyan(prettyObject);
|
|
150
149
|
}
|
|
151
150
|
|
|
152
151
|
this.outputStream(
|
|
@@ -176,17 +175,17 @@ export class Logger {
|
|
|
176
175
|
private colorFromLogLevel(level: LogLevel) {
|
|
177
176
|
switch (level) {
|
|
178
177
|
case LogLevel.trace:
|
|
179
|
-
return
|
|
178
|
+
return ansi.gray;
|
|
180
179
|
case LogLevel.debug:
|
|
181
|
-
return
|
|
180
|
+
return ansi.blue;
|
|
182
181
|
case LogLevel.info:
|
|
183
|
-
return
|
|
182
|
+
return ansi.green;
|
|
184
183
|
case LogLevel.warn:
|
|
185
|
-
return
|
|
184
|
+
return ansi.yellow;
|
|
186
185
|
case LogLevel.error:
|
|
187
|
-
return
|
|
186
|
+
return ansi.red;
|
|
188
187
|
case LogLevel.fatal:
|
|
189
|
-
return
|
|
188
|
+
return ansi.magenta;
|
|
190
189
|
}
|
|
191
190
|
}
|
|
192
191
|
}
|
package/initializers/mcp.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
3
|
-
import colors from "colors";
|
|
4
3
|
import { randomUUID } from "crypto";
|
|
5
4
|
import { api, logger } from "../api";
|
|
6
5
|
import { Initializer } from "../classes/Initializer";
|
|
7
6
|
import { ErrorType, TypedError } from "../classes/TypedError";
|
|
8
7
|
import { config } from "../config";
|
|
8
|
+
import { ansi } from "../util/ansi";
|
|
9
9
|
import { buildCorsHeaders, getExternalOrigin } from "../util/http";
|
|
10
10
|
import {
|
|
11
11
|
createMcpServer,
|
|
@@ -236,7 +236,7 @@ export class McpInitializer extends Initializer {
|
|
|
236
236
|
|
|
237
237
|
const mcpUrl = `${config.server.web.applicationUrl}${mcpRoute}`;
|
|
238
238
|
const startMessage = `started MCP server @ ${mcpUrl}`;
|
|
239
|
-
logger.info(logger.colorize ?
|
|
239
|
+
logger.info(logger.colorize ? ansi.bgBlue(startMessage) : startMessage);
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
async stop() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keryx",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.6",
|
|
4
4
|
"module": "index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -82,31 +82,27 @@
|
|
|
82
82
|
"prepublishOnly": "cp ../../README.md ."
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
86
|
-
"@opentelemetry/api": "^1.9.
|
|
87
|
-
"@opentelemetry/sdk-metrics": "^
|
|
88
|
-
"
|
|
89
|
-
"cookie": "^0.6.0",
|
|
90
|
-
"ioredis": "^5.9.2",
|
|
85
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
86
|
+
"@opentelemetry/api": "^1.9.1",
|
|
87
|
+
"@opentelemetry/sdk-metrics": "^2.6.1",
|
|
88
|
+
"ioredis": "^5.10.1",
|
|
91
89
|
"mustache": "^4.2.0",
|
|
92
90
|
"node-resque": "^9.5.0",
|
|
93
|
-
"pg": "^8.
|
|
91
|
+
"pg": "^8.20.0",
|
|
94
92
|
"ts-morph": "^27.0.2",
|
|
95
|
-
"typescript": "^
|
|
96
|
-
"commander": "^
|
|
97
|
-
"@types/cookie": "^0.6.0",
|
|
93
|
+
"typescript": "^6.0.2",
|
|
94
|
+
"commander": "^14.0.3",
|
|
98
95
|
"@types/mustache": "^4.2.6",
|
|
99
|
-
"@types/pg": "^8.
|
|
96
|
+
"@types/pg": "^8.20.0"
|
|
100
97
|
},
|
|
101
98
|
"peerDependencies": {
|
|
102
|
-
"drizzle-orm": "^0.45.
|
|
99
|
+
"drizzle-orm": "^0.45.2",
|
|
103
100
|
"drizzle-zod": "^0.8.3",
|
|
104
101
|
"zod": "^4.3.6"
|
|
105
102
|
},
|
|
106
103
|
"devDependencies": {
|
|
107
104
|
"@types/bun": "^1.3.11",
|
|
108
|
-
"
|
|
109
|
-
"drizzle-kit": "^0.31.9",
|
|
105
|
+
"drizzle-kit": "^0.31.10",
|
|
110
106
|
"drizzle-zod": "^0.8.3"
|
|
111
107
|
}
|
|
112
108
|
}
|
package/servers/web.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { parse } from "node:url";
|
|
2
2
|
import type { ServerWebSocket } from "bun";
|
|
3
|
-
import colors from "colors";
|
|
4
|
-
import cookie from "cookie";
|
|
5
3
|
import { randomUUID } from "crypto";
|
|
6
4
|
import { api, logger } from "../api";
|
|
7
5
|
import { type HTTP_METHOD } from "../classes/Action";
|
|
@@ -11,6 +9,7 @@ import { StreamingResponse } from "../classes/StreamingResponse";
|
|
|
11
9
|
import { ErrorStatusCodes, ErrorType, TypedError } from "../classes/TypedError";
|
|
12
10
|
import { config } from "../config";
|
|
13
11
|
import type { PubSubMessage } from "../initializers/pubsub";
|
|
12
|
+
import { ansi } from "../util/ansi";
|
|
14
13
|
import { isOriginAllowed } from "../util/http";
|
|
15
14
|
import { compressResponse } from "../util/webCompression";
|
|
16
15
|
import {
|
|
@@ -68,7 +67,7 @@ export class WebServer extends Server<ReturnType<typeof Bun.serve>> {
|
|
|
68
67
|
this.port = server.port ?? config.server.web.port;
|
|
69
68
|
this.url = `http://${config.server.web.host}:${this.port}`;
|
|
70
69
|
const startMessage = `started server @ ${this.url}`;
|
|
71
|
-
logger.info(logger.colorize ?
|
|
70
|
+
logger.info(logger.colorize ? ansi.bgBlue(startMessage) : startMessage);
|
|
72
71
|
} catch (e) {
|
|
73
72
|
await Bun.sleep(1000);
|
|
74
73
|
startupAttempts++;
|
|
@@ -144,8 +143,8 @@ export class WebServer extends Server<ReturnType<typeof Bun.serve>> {
|
|
|
144
143
|
) {
|
|
145
144
|
const ip = server.requestIP(req)?.address || "unknown-IP";
|
|
146
145
|
const headers = req.headers;
|
|
147
|
-
const cookies =
|
|
148
|
-
const id = cookies
|
|
146
|
+
const cookies = new Bun.CookieMap(req.headers.get("cookie") ?? "");
|
|
147
|
+
const id = cookies.get(config.session.cookieName) || randomUUID();
|
|
149
148
|
|
|
150
149
|
// Reject new WebSocket upgrades during shutdown
|
|
151
150
|
if (
|
package/util/ansi.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const RESET = "\x1b[0m";
|
|
2
|
+
|
|
3
|
+
/** ANSI terminal color helpers. Each wraps a string in an escape code and reset suffix. */
|
|
4
|
+
export const ansi = {
|
|
5
|
+
gray: (s: string) => `\x1b[90m${s}${RESET}`,
|
|
6
|
+
blue: (s: string) => `\x1b[34m${s}${RESET}`,
|
|
7
|
+
cyan: (s: string) => `\x1b[36m${s}${RESET}`,
|
|
8
|
+
green: (s: string) => `\x1b[32m${s}${RESET}`,
|
|
9
|
+
yellow: (s: string) => `\x1b[33m${s}${RESET}`,
|
|
10
|
+
red: (s: string) => `\x1b[31m${s}${RESET}`,
|
|
11
|
+
magenta: (s: string) => `\x1b[35m${s}${RESET}`,
|
|
12
|
+
bgBlue: (s: string) => `\x1b[44m${s}${RESET}`,
|
|
13
|
+
bgMagenta: (s: string) => `\x1b[45m${s}${RESET}`,
|
|
14
|
+
};
|