@ibm/ibmi-mcp-server 0.2.0 → 0.3.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/README.md +140 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +14 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/resolver.d.ts.map +1 -1
- package/dist/config/resolver.js.map +1 -1
- package/dist/ibmi-mcp-server/tools/executeSql.tool.d.ts +80 -0
- package/dist/ibmi-mcp-server/tools/executeSql.tool.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/tools/executeSql.tool.js +356 -0
- package/dist/ibmi-mcp-server/tools/executeSql.tool.js.map +1 -0
- package/dist/ibmi-mcp-server/tools/generateSql.tool.d.ts +36 -0
- package/dist/ibmi-mcp-server/tools/generateSql.tool.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/tools/generateSql.tool.js +281 -0
- package/dist/ibmi-mcp-server/tools/generateSql.tool.js.map +1 -0
- package/dist/ibmi-mcp-server/tools/index.d.ts +85 -0
- package/dist/ibmi-mcp-server/tools/index.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/tools/index.js +21 -0
- package/dist/ibmi-mcp-server/tools/index.js.map +1 -0
- package/dist/ibmi-mcp-server/utils/config/configParser.d.ts +9 -0
- package/dist/ibmi-mcp-server/utils/config/configParser.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/configParser.js +58 -0
- package/dist/ibmi-mcp-server/utils/config/configParser.js.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolDefinitions.d.ts +4 -4
- package/dist/ibmi-mcp-server/utils/config/toolDefinitions.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolDefinitions.js +7 -8
- package/dist/ibmi-mcp-server/utils/config/toolDefinitions.js.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolFactory.d.ts +0 -8
- package/dist/ibmi-mcp-server/utils/config/toolFactory.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolFactory.js +0 -31
- package/dist/ibmi-mcp-server/utils/config/toolFactory.js.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolsetManager.d.ts +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolsetManager.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolsetManager.js +2 -2
- package/dist/ibmi-mcp-server/utils/config/toolsetManager.js.map +1 -1
- package/dist/ibmi-mcp-server/utils/language/document.d.ts +26 -0
- package/dist/ibmi-mcp-server/utils/language/document.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/document.js +318 -0
- package/dist/ibmi-mcp-server/utils/language/document.js.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/statement.d.ts +43 -0
- package/dist/ibmi-mcp-server/utils/language/statement.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/statement.js +796 -0
- package/dist/ibmi-mcp-server/utils/language/statement.js.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/tokens.d.ts +32 -0
- package/dist/ibmi-mcp-server/utils/language/tokens.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/tokens.js +532 -0
- package/dist/ibmi-mcp-server/utils/language/tokens.js.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/types.d.ts +138 -0
- package/dist/ibmi-mcp-server/utils/language/types.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/types.js +93 -0
- package/dist/ibmi-mcp-server/utils/language/types.js.map +1 -0
- package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.d.ts +48 -0
- package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.js +93 -0
- package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.js.map +1 -0
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.d.ts +35 -59
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.js +108 -288
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.js.map +1 -1
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.d.ts +54 -0
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.js +91 -0
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.js.map +1 -0
- package/dist/mcp-server/tools/index.d.ts +13 -2
- package/dist/mcp-server/tools/index.d.ts.map +1 -1
- package/dist/mcp-server/tools/index.js +29 -9
- package/dist/mcp-server/tools/index.js.map +1 -1
- package/dist/mcp-server/tools/utils/index.d.ts +7 -0
- package/dist/mcp-server/tools/utils/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/index.js +7 -0
- package/dist/mcp-server/tools/utils/index.js.map +1 -0
- package/dist/mcp-server/tools/utils/tool-factory.d.ts +129 -0
- package/dist/mcp-server/tools/utils/tool-factory.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/tool-factory.js +179 -0
- package/dist/mcp-server/tools/utils/tool-factory.js.map +1 -0
- package/dist/mcp-server/tools/utils/types.d.ts +117 -0
- package/dist/mcp-server/tools/utils/types.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/types.js +11 -0
- package/dist/mcp-server/tools/utils/types.js.map +1 -0
- package/dist/mcp-server/transports/core/cleanupTransformStream.d.ts +26 -0
- package/dist/mcp-server/transports/core/cleanupTransformStream.d.ts.map +1 -0
- package/dist/mcp-server/transports/core/cleanupTransformStream.js +60 -0
- package/dist/mcp-server/transports/core/cleanupTransformStream.js.map +1 -0
- package/dist/mcp-server/transports/core/statefulTransportManager.d.ts +1 -1
- package/dist/mcp-server/transports/core/statefulTransportManager.d.ts.map +1 -1
- package/dist/mcp-server/transports/core/statefulTransportManager.js +50 -40
- package/dist/mcp-server/transports/core/statefulTransportManager.js.map +1 -1
- package/dist/mcp-server/transports/core/statelessTransportManager.d.ts +2 -13
- package/dist/mcp-server/transports/core/statelessTransportManager.d.ts.map +1 -1
- package/dist/mcp-server/transports/core/statelessTransportManager.js +35 -62
- package/dist/mcp-server/transports/core/statelessTransportManager.js.map +1 -1
- package/dist/mcp-server/transports/core/transportRequest.d.ts +1 -2
- package/dist/mcp-server/transports/core/transportRequest.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/mcpTransportMiddleware.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/mcpTransportMiddleware.js +1 -3
- package/dist/mcp-server/transports/http/mcpTransportMiddleware.js.map +1 -1
- package/package.json +21 -22
- package/dist/ibmi-mcp-server/tools/executeSql/index.d.ts +0 -9
- package/dist/ibmi-mcp-server/tools/executeSql/index.d.ts.map +0 -1
- package/dist/ibmi-mcp-server/tools/executeSql/index.js +0 -9
- package/dist/ibmi-mcp-server/tools/executeSql/index.js.map +0 -1
- package/dist/ibmi-mcp-server/tools/executeSql/logic.d.ts +0 -51
- package/dist/ibmi-mcp-server/tools/executeSql/logic.d.ts.map +0 -1
- package/dist/ibmi-mcp-server/tools/executeSql/logic.js +0 -179
- package/dist/ibmi-mcp-server/tools/executeSql/logic.js.map +0 -1
- package/dist/ibmi-mcp-server/tools/executeSql/registration.d.ts +0 -52
- package/dist/ibmi-mcp-server/tools/executeSql/registration.d.ts.map +0 -1
- package/dist/ibmi-mcp-server/tools/executeSql/registration.js +0 -161
- package/dist/ibmi-mcp-server/tools/executeSql/registration.js.map +0 -1
- package/dist/ibmi-mcp-server/tools/generateSql/index.d.ts +0 -13
- package/dist/ibmi-mcp-server/tools/generateSql/index.d.ts.map +0 -1
- package/dist/ibmi-mcp-server/tools/generateSql/index.js +0 -13
- package/dist/ibmi-mcp-server/tools/generateSql/index.js.map +0 -1
- package/dist/ibmi-mcp-server/tools/generateSql/logic.d.ts +0 -64
- package/dist/ibmi-mcp-server/tools/generateSql/logic.d.ts.map +0 -1
- package/dist/ibmi-mcp-server/tools/generateSql/logic.js +0 -190
- package/dist/ibmi-mcp-server/tools/generateSql/logic.js.map +0 -1
- package/dist/ibmi-mcp-server/tools/generateSql/registration.d.ts +0 -18
- package/dist/ibmi-mcp-server/tools/generateSql/registration.d.ts.map +0 -1
- package/dist/ibmi-mcp-server/tools/generateSql/registration.js +0 -64
- package/dist/ibmi-mcp-server/tools/generateSql/registration.js.map +0 -1
- package/dist/mcp-server/tools/catFactFetcher/index.d.ts +0 -8
- package/dist/mcp-server/tools/catFactFetcher/index.d.ts.map +0 -1
- package/dist/mcp-server/tools/catFactFetcher/index.js +0 -8
- package/dist/mcp-server/tools/catFactFetcher/index.js.map +0 -1
- package/dist/mcp-server/tools/catFactFetcher/logic.d.ts +0 -52
- package/dist/mcp-server/tools/catFactFetcher/logic.d.ts.map +0 -1
- package/dist/mcp-server/tools/catFactFetcher/logic.js +0 -95
- package/dist/mcp-server/tools/catFactFetcher/logic.js.map +0 -1
- package/dist/mcp-server/tools/catFactFetcher/registration.d.ts +0 -9
- package/dist/mcp-server/tools/catFactFetcher/registration.d.ts.map +0 -1
- package/dist/mcp-server/tools/catFactFetcher/registration.js +0 -43
- package/dist/mcp-server/tools/catFactFetcher/registration.js.map +0 -1
- package/dist/mcp-server/tools/echoTool/index.d.ts +0 -13
- package/dist/mcp-server/tools/echoTool/index.d.ts.map +0 -1
- package/dist/mcp-server/tools/echoTool/index.js +0 -13
- package/dist/mcp-server/tools/echoTool/index.js.map +0 -1
- package/dist/mcp-server/tools/echoTool/logic.d.ts +0 -69
- package/dist/mcp-server/tools/echoTool/logic.d.ts.map +0 -1
- package/dist/mcp-server/tools/echoTool/logic.js +0 -119
- package/dist/mcp-server/tools/echoTool/logic.js.map +0 -1
- package/dist/mcp-server/tools/echoTool/registration.d.ts +0 -9
- package/dist/mcp-server/tools/echoTool/registration.d.ts.map +0 -1
- package/dist/mcp-server/tools/echoTool/registration.js +0 -45
- package/dist/mcp-server/tools/echoTool/registration.js.map +0 -1
- package/dist/mcp-server/tools/imageTest/index.d.ts +0 -7
- package/dist/mcp-server/tools/imageTest/index.d.ts.map +0 -1
- package/dist/mcp-server/tools/imageTest/index.js +0 -7
- package/dist/mcp-server/tools/imageTest/index.js.map +0 -1
- package/dist/mcp-server/tools/imageTest/logic.d.ts +0 -27
- package/dist/mcp-server/tools/imageTest/logic.d.ts.map +0 -1
- package/dist/mcp-server/tools/imageTest/logic.js +0 -44
- package/dist/mcp-server/tools/imageTest/logic.js.map +0 -1
- package/dist/mcp-server/tools/imageTest/registration.d.ts +0 -9
- package/dist/mcp-server/tools/imageTest/registration.d.ts.map +0 -1
- package/dist/mcp-server/tools/imageTest/registration.js +0 -49
- package/dist/mcp-server/tools/imageTest/registration.js.map +0 -1
- package/dist/mcp-server/tools/utils/tool-utils.d.ts +0 -43
- package/dist/mcp-server/tools/utils/tool-utils.d.ts.map +0 -1
- package/dist/mcp-server/tools/utils/tool-utils.js +0 -44
- package/dist/mcp-server/tools/utils/tool-utils.js.map +0 -1
- package/dist/mcp-server/transports/core/headerUtils.d.ts +0 -27
- package/dist/mcp-server/transports/core/headerUtils.d.ts.map +0 -1
- package/dist/mcp-server/transports/core/headerUtils.js +0 -53
- package/dist/mcp-server/transports/core/headerUtils.js.map +0 -1
- package/dist/mcp-server/transports/core/honoNodeBridge.d.ts +0 -77
- package/dist/mcp-server/transports/core/honoNodeBridge.d.ts.map +0 -1
- package/dist/mcp-server/transports/core/honoNodeBridge.js +0 -150
- package/dist/mcp-server/transports/core/honoNodeBridge.js.map +0 -1
- package/dist/services/duck-db/duckDBConnectionManager.d.ts +0 -55
- package/dist/services/duck-db/duckDBConnectionManager.d.ts.map +0 -1
- package/dist/services/duck-db/duckDBConnectionManager.js +0 -184
- package/dist/services/duck-db/duckDBConnectionManager.js.map +0 -1
- package/dist/services/duck-db/duckDBQueryExecutor.d.ts +0 -18
- package/dist/services/duck-db/duckDBQueryExecutor.d.ts.map +0 -1
- package/dist/services/duck-db/duckDBQueryExecutor.js +0 -115
- package/dist/services/duck-db/duckDBQueryExecutor.js.map +0 -1
- package/dist/services/duck-db/duckDBService.d.ts +0 -27
- package/dist/services/duck-db/duckDBService.d.ts.map +0 -1
- package/dist/services/duck-db/duckDBService.js +0 -151
- package/dist/services/duck-db/duckDBService.js.map +0 -1
- package/dist/services/duck-db/types.d.ts +0 -135
- package/dist/services/duck-db/types.d.ts.map +0 -1
- package/dist/services/duck-db/types.js +0 -6
- package/dist/services/duck-db/types.js.map +0 -1
- package/dist/services/llm-providers/openRouterProvider.d.ts +0 -36
- package/dist/services/llm-providers/openRouterProvider.d.ts.map +0 -1
- package/dist/services/llm-providers/openRouterProvider.js +0 -235
- package/dist/services/llm-providers/openRouterProvider.js.map +0 -1
- package/dist/services/supabase/supabaseClient.d.ts +0 -25
- package/dist/services/supabase/supabaseClient.d.ts.map +0 -1
- package/dist/services/supabase/supabaseClient.js +0 -68
- package/dist/services/supabase/supabaseClient.js.map +0 -1
- package/dist/storage/duckdbExample.d.ts +0 -8
- package/dist/storage/duckdbExample.d.ts.map +0 -1
- package/dist/storage/duckdbExample.js +0 -197
- package/dist/storage/duckdbExample.js.map +0 -1
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Implements the DuckDB service for interacting with a DuckDB database.
|
|
3
|
-
* @module services/duck-db/duckDBService
|
|
4
|
-
*/
|
|
5
|
-
import * as duckdb from "@duckdb/node-api";
|
|
6
|
-
import { DuckDBQueryResult, DuckDBServiceConfig, IDuckDBService } from "./types.js";
|
|
7
|
-
export declare class DuckDBService implements IDuckDBService {
|
|
8
|
-
private connectionManager;
|
|
9
|
-
private queryExecutor;
|
|
10
|
-
private isInitialized;
|
|
11
|
-
constructor();
|
|
12
|
-
initialize(config?: DuckDBServiceConfig): Promise<void>;
|
|
13
|
-
private ensureInitialized;
|
|
14
|
-
private validateParams;
|
|
15
|
-
run(sql: string, params?: unknown[]): Promise<void>;
|
|
16
|
-
query<T = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<DuckDBQueryResult<T>>;
|
|
17
|
-
stream(sql: string, params?: unknown[]): Promise<duckdb.DuckDBResult>;
|
|
18
|
-
prepare(sql: string): Promise<duckdb.DuckDBPreparedStatement>;
|
|
19
|
-
beginTransaction(): Promise<void>;
|
|
20
|
-
commitTransaction(): Promise<void>;
|
|
21
|
-
rollbackTransaction(): Promise<void>;
|
|
22
|
-
loadExtension(extensionName: string): Promise<void>;
|
|
23
|
-
close(): Promise<void>;
|
|
24
|
-
getRawConnection(): duckdb.DuckDBConnection | null;
|
|
25
|
-
getRawInstance(): duckdb.DuckDBInstance | null;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=duckDBService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"duckDBService.d.ts","sourceRoot":"","sources":["../../../src/services/duck-db/duckDBService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAU3C,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,iBAAiB,CAA0B;IACnD,OAAO,CAAC,aAAa,CAAoC;IACzD,OAAO,CAAC,aAAa,CAAS;;IAMxB,UAAU,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC7D,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,cAAc;IAiBhB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAUnD,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAU1B,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;IAUrE,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC;IAS7D,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAQjC,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAQlC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAQpC,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYnD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB5B,gBAAgB,IAAI,MAAM,CAAC,gBAAgB,GAAG,IAAI;IAOlD,cAAc,IAAI,MAAM,CAAC,cAAc,GAAG,IAAI;CAM/C"}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Implements the DuckDB service for interacting with a DuckDB database.
|
|
3
|
-
* @module services/duck-db/duckDBService
|
|
4
|
-
*/
|
|
5
|
-
import { JsonRpcErrorCode, McpError } from "../../types-global/errors.js";
|
|
6
|
-
import { ErrorHandler, logger, requestContextService, } from "../../utils/index.js";
|
|
7
|
-
import { DuckDBConnectionManager } from "./duckDBConnectionManager.js";
|
|
8
|
-
import { DuckDBQueryExecutor } from "./duckDBQueryExecutor.js";
|
|
9
|
-
export class DuckDBService {
|
|
10
|
-
connectionManager;
|
|
11
|
-
queryExecutor = null;
|
|
12
|
-
isInitialized = false;
|
|
13
|
-
constructor() {
|
|
14
|
-
this.connectionManager = new DuckDBConnectionManager();
|
|
15
|
-
}
|
|
16
|
-
async initialize(config) {
|
|
17
|
-
const context = requestContextService.createRequestContext({
|
|
18
|
-
operation: "DuckDBService.initialize",
|
|
19
|
-
initialData: config,
|
|
20
|
-
});
|
|
21
|
-
if (this.isInitialized) {
|
|
22
|
-
logger.warning(context, "DuckDBService already initialized. Close first to re-initialize.");
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
return ErrorHandler.tryCatch(async () => {
|
|
26
|
-
await this.connectionManager.initialize(config);
|
|
27
|
-
const connection = this.connectionManager.getConnection();
|
|
28
|
-
this.queryExecutor = new DuckDBQueryExecutor(connection);
|
|
29
|
-
this.isInitialized = true;
|
|
30
|
-
logger.info(context, "DuckDBService initialized successfully.");
|
|
31
|
-
}, {
|
|
32
|
-
operation: "DuckDBService.initialize",
|
|
33
|
-
context,
|
|
34
|
-
input: config,
|
|
35
|
-
errorCode: JsonRpcErrorCode.InitializationFailed,
|
|
36
|
-
critical: true,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
ensureInitialized(context) {
|
|
40
|
-
this.connectionManager.ensureInitialized(context); // Delegate to manager
|
|
41
|
-
if (!this.queryExecutor) {
|
|
42
|
-
// This check is mostly for type safety, as connectionManager.ensureInitialized should cover it
|
|
43
|
-
throw new McpError(JsonRpcErrorCode.ServiceUnavailable, "DuckDBQueryExecutor not available. DuckDBService may not be fully initialized.", context);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
validateParams(params, context) {
|
|
47
|
-
if (params === undefined) {
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
if (Array.isArray(params)) {
|
|
51
|
-
return params;
|
|
52
|
-
}
|
|
53
|
-
throw new McpError(JsonRpcErrorCode.InvalidParams, "DuckDB service only supports array-style parameters, not named objects.", context);
|
|
54
|
-
}
|
|
55
|
-
async run(sql, params) {
|
|
56
|
-
const context = requestContextService.createRequestContext({
|
|
57
|
-
operation: "DuckDBService.run",
|
|
58
|
-
initialData: { sql, params },
|
|
59
|
-
});
|
|
60
|
-
this.ensureInitialized(context);
|
|
61
|
-
const validatedParams = this.validateParams(params, context);
|
|
62
|
-
return this.queryExecutor.run(sql, validatedParams);
|
|
63
|
-
}
|
|
64
|
-
async query(sql, params) {
|
|
65
|
-
const context = requestContextService.createRequestContext({
|
|
66
|
-
operation: "DuckDBService.query",
|
|
67
|
-
initialData: { sql, params },
|
|
68
|
-
});
|
|
69
|
-
this.ensureInitialized(context);
|
|
70
|
-
const validatedParams = this.validateParams(params, context);
|
|
71
|
-
return this.queryExecutor.query(sql, validatedParams);
|
|
72
|
-
}
|
|
73
|
-
async stream(sql, params) {
|
|
74
|
-
const context = requestContextService.createRequestContext({
|
|
75
|
-
operation: "DuckDBService.stream",
|
|
76
|
-
initialData: { sql, params },
|
|
77
|
-
});
|
|
78
|
-
this.ensureInitialized(context);
|
|
79
|
-
const validatedParams = this.validateParams(params, context);
|
|
80
|
-
return this.queryExecutor.stream(sql, validatedParams);
|
|
81
|
-
}
|
|
82
|
-
async prepare(sql) {
|
|
83
|
-
const context = requestContextService.createRequestContext({
|
|
84
|
-
operation: "DuckDBService.prepare",
|
|
85
|
-
initialData: { sql },
|
|
86
|
-
});
|
|
87
|
-
this.ensureInitialized(context);
|
|
88
|
-
return this.queryExecutor.prepare(sql);
|
|
89
|
-
}
|
|
90
|
-
async beginTransaction() {
|
|
91
|
-
const context = requestContextService.createRequestContext({
|
|
92
|
-
operation: "DuckDBService.beginTransaction",
|
|
93
|
-
});
|
|
94
|
-
this.ensureInitialized(context);
|
|
95
|
-
return this.queryExecutor.beginTransaction();
|
|
96
|
-
}
|
|
97
|
-
async commitTransaction() {
|
|
98
|
-
const context = requestContextService.createRequestContext({
|
|
99
|
-
operation: "DuckDBService.commitTransaction",
|
|
100
|
-
});
|
|
101
|
-
this.ensureInitialized(context);
|
|
102
|
-
return this.queryExecutor.commitTransaction();
|
|
103
|
-
}
|
|
104
|
-
async rollbackTransaction() {
|
|
105
|
-
const context = requestContextService.createRequestContext({
|
|
106
|
-
operation: "DuckDBService.rollbackTransaction",
|
|
107
|
-
});
|
|
108
|
-
this.ensureInitialized(context);
|
|
109
|
-
return this.queryExecutor.rollbackTransaction();
|
|
110
|
-
}
|
|
111
|
-
async loadExtension(extensionName) {
|
|
112
|
-
const context = requestContextService.createRequestContext({
|
|
113
|
-
operation: "DuckDBService.loadExtension",
|
|
114
|
-
initialData: { extensionName },
|
|
115
|
-
});
|
|
116
|
-
// ensureInitialized is implicitly called by connectionManager.loadExtension
|
|
117
|
-
// if we call ensureInitialized here, it uses the service's context,
|
|
118
|
-
// but loadExtension in manager will create its own.
|
|
119
|
-
// It's better to let the manager handle its own initialization checks.
|
|
120
|
-
return this.connectionManager.loadExtension(extensionName, context);
|
|
121
|
-
}
|
|
122
|
-
async close() {
|
|
123
|
-
const context = requestContextService.createRequestContext({
|
|
124
|
-
operation: "DuckDBService.close",
|
|
125
|
-
});
|
|
126
|
-
// No need to check this.isInitialized here, connectionManager.close() handles it.
|
|
127
|
-
return ErrorHandler.tryCatch(async () => {
|
|
128
|
-
await this.connectionManager.close();
|
|
129
|
-
this.queryExecutor = null;
|
|
130
|
-
this.isInitialized = false;
|
|
131
|
-
logger.info(context, "DuckDBService closed successfully.");
|
|
132
|
-
}, {
|
|
133
|
-
operation: "DuckDBService.close",
|
|
134
|
-
context,
|
|
135
|
-
errorCode: JsonRpcErrorCode.InternalError,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
getRawConnection() {
|
|
139
|
-
if (this.connectionManager.isServiceInitialized) {
|
|
140
|
-
return this.connectionManager.getConnection();
|
|
141
|
-
}
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
getRawInstance() {
|
|
145
|
-
if (this.connectionManager.isServiceInitialized) {
|
|
146
|
-
return this.connectionManager.getInstance();
|
|
147
|
-
}
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
//# sourceMappingURL=duckDBService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"duckDBService.js","sourceRoot":"","sources":["../../../src/services/duck-db/duckDBService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,QAAQ,E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AAgB;QACd,IAAI,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,EAAE,CAAC;YAChD,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE,CAAC;QAChD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc;QACZ,IAAI,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,EAAE,CAAC;YAChD,OAAO,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,CAAC;QAC9C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Defines types and interfaces for the DuckDB service.
|
|
3
|
-
* @module services/duck-db/types
|
|
4
|
-
*/
|
|
5
|
-
import * as duckdb from "@duckdb/node-api";
|
|
6
|
-
/**
|
|
7
|
-
* Configuration options for initializing the DuckDB service.
|
|
8
|
-
*/
|
|
9
|
-
export interface DuckDBServiceConfig {
|
|
10
|
-
/**
|
|
11
|
-
* The path to the database file.
|
|
12
|
-
* Use ':memory:' for an in-memory database.
|
|
13
|
-
* If undefined, defaults to an in-memory database.
|
|
14
|
-
*/
|
|
15
|
-
dbPath?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Optional DuckDB launch configurations.
|
|
18
|
-
* Refer to DuckDB documentation for available options.
|
|
19
|
-
* Example: { allow_unsigned_extensions: 'true' }
|
|
20
|
-
*/
|
|
21
|
-
launchConfig?: Record<string, string>;
|
|
22
|
-
/**
|
|
23
|
-
* List of extensions to install and load upon initialization.
|
|
24
|
-
* Example: ['httpfs', 'json']
|
|
25
|
-
*/
|
|
26
|
-
extensions?: string[];
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Represents a query to be executed.
|
|
30
|
-
*/
|
|
31
|
-
export interface DuckDBQuery {
|
|
32
|
-
sql: string;
|
|
33
|
-
params?: unknown[];
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Represents the result of a query execution.
|
|
37
|
-
*/
|
|
38
|
-
export interface DuckDBQueryResult<T = Record<string, unknown>> {
|
|
39
|
-
rows: T[];
|
|
40
|
-
columnNames: string[];
|
|
41
|
-
columnTypes: duckdb.DuckDBTypeId[];
|
|
42
|
-
rowCount: number;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Interface for the DuckDB service.
|
|
46
|
-
*/
|
|
47
|
-
export interface IDuckDBService {
|
|
48
|
-
/**
|
|
49
|
-
* Initializes the DuckDB service with the given configuration.
|
|
50
|
-
* Must be called before any other operations.
|
|
51
|
-
* @param {DuckDBServiceConfig} config - The configuration for the DuckDB service.
|
|
52
|
-
* @returns {Promise<void>}
|
|
53
|
-
* @throws {McpError} If initialization fails.
|
|
54
|
-
*/
|
|
55
|
-
initialize(config?: DuckDBServiceConfig): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* Executes a SQL query that does not return a large result set (e.g., CREATE, INSERT, UPDATE, DELETE).
|
|
58
|
-
* @param {string} sql - The SQL query string.
|
|
59
|
-
* @param {unknown[]} [params] - Optional parameters for the query.
|
|
60
|
-
* @returns {Promise<void>}
|
|
61
|
-
* @throws {McpError} If the query fails or the service is not initialized.
|
|
62
|
-
*/
|
|
63
|
-
run(sql: string, params?: unknown[]): Promise<void>;
|
|
64
|
-
/**
|
|
65
|
-
* Executes a SQL query and returns all resulting rows.
|
|
66
|
-
* Suitable for queries that return a manageable number of rows.
|
|
67
|
-
* @template T - The expected type of the row objects.
|
|
68
|
-
* @param {string} sql - The SQL query string.
|
|
69
|
-
* @param {unknown[]} [params] - Optional parameters for the query.
|
|
70
|
-
* @returns {Promise<DuckDBQueryResult<T>>} The query result.
|
|
71
|
-
* @throws {McpError} If the query fails or the service is not initialized.
|
|
72
|
-
*/
|
|
73
|
-
query<T = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<DuckDBQueryResult<T>>;
|
|
74
|
-
/**
|
|
75
|
-
* Executes a SQL query and provides a streaming result reader.
|
|
76
|
-
* Suitable for queries that return very large result sets.
|
|
77
|
-
* The caller is responsible for closing the stream.
|
|
78
|
-
* @param {string} sql - The SQL query string.
|
|
79
|
-
* @param {unknown[]} [params] - Optional parameters for the query.
|
|
80
|
-
* @returns {Promise<duckdb.DuckDBStreamingResult>} A streaming result object.
|
|
81
|
-
* @throws {McpError} If the query fails or the service is not initialized.
|
|
82
|
-
*/
|
|
83
|
-
stream(sql: string, params?: unknown[]): Promise<duckdb.DuckDBResult>;
|
|
84
|
-
/**
|
|
85
|
-
* Creates a prepared statement.
|
|
86
|
-
* @param {string} sql - The SQL query string for the prepared statement.
|
|
87
|
-
* @returns {Promise<duckdb.DuckDBPreparedStatement>} The prepared statement object.
|
|
88
|
-
* @throws {McpError} If preparing the statement fails or the service is not initialized.
|
|
89
|
-
*/
|
|
90
|
-
prepare(sql: string): Promise<duckdb.DuckDBPreparedStatement>;
|
|
91
|
-
/**
|
|
92
|
-
* Begins a new transaction.
|
|
93
|
-
* @returns {Promise<void>}
|
|
94
|
-
* @throws {McpError} If starting the transaction fails or the service is not initialized.
|
|
95
|
-
*/
|
|
96
|
-
beginTransaction(): Promise<void>;
|
|
97
|
-
/**
|
|
98
|
-
* Commits the current transaction.
|
|
99
|
-
* @returns {Promise<void>}
|
|
100
|
-
* @throws {McpError} If committing the transaction fails or the service is not initialized.
|
|
101
|
-
*/
|
|
102
|
-
commitTransaction(): Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Rolls back the current transaction.
|
|
105
|
-
* @returns {Promise<void>}
|
|
106
|
-
* @throws {McpError} If rolling back the transaction fails or the service is not initialized.
|
|
107
|
-
*/
|
|
108
|
-
rollbackTransaction(): Promise<void>;
|
|
109
|
-
/**
|
|
110
|
-
* Installs and loads a DuckDB extension.
|
|
111
|
-
* @param {string} extensionName - The name of the extension to install and load.
|
|
112
|
-
* @returns {Promise<void>}
|
|
113
|
-
* @throws {McpError} If installing or loading the extension fails or the service is not initialized.
|
|
114
|
-
*/
|
|
115
|
-
loadExtension(extensionName: string): Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* Closes the DuckDB connection and instance.
|
|
118
|
-
* @returns {Promise<void>}
|
|
119
|
-
* @throws {McpError} If closing fails.
|
|
120
|
-
*/
|
|
121
|
-
close(): Promise<void>;
|
|
122
|
-
/**
|
|
123
|
-
* Gets the underlying DuckDB connection object.
|
|
124
|
-
* Use with caution, primarily for advanced scenarios not covered by the service interface.
|
|
125
|
-
* @returns {duckdb.DuckDBConnection | null} The connection object, or null if not initialized.
|
|
126
|
-
*/
|
|
127
|
-
getRawConnection(): duckdb.DuckDBConnection | null;
|
|
128
|
-
/**
|
|
129
|
-
* Gets the underlying DuckDB instance object.
|
|
130
|
-
* Use with caution, primarily for advanced scenarios not covered by the service interface.
|
|
131
|
-
* @returns {duckdb.DuckDBInstance | null} The instance object, or null if not initialized.
|
|
132
|
-
*/
|
|
133
|
-
getRawInstance(): duckdb.DuckDBInstance | null;
|
|
134
|
-
}
|
|
135
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/duck-db/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEtC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OA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;OAIG;IACH,gBAAgB,IAAI,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAEnD;;;;OAIG;IACH,cAAc,IAAI,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;CAChD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/duck-db/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ChatCompletion, ChatCompletionChunk, ChatCompletionCreateParamsNonStreaming, ChatCompletionCreateParamsStreaming } from "openai/resources/chat/completions";
|
|
2
|
-
import { Stream } from "openai/streaming";
|
|
3
|
-
import { RequestContext } from "../../utils/internal/requestContext.js";
|
|
4
|
-
/**
|
|
5
|
-
* Options for configuring the OpenRouter client.
|
|
6
|
-
*/
|
|
7
|
-
export interface OpenRouterClientOptions {
|
|
8
|
-
apiKey?: string;
|
|
9
|
-
baseURL?: string;
|
|
10
|
-
siteUrl?: string;
|
|
11
|
-
siteName?: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Defines the parameters for an OpenRouter chat completion request.
|
|
15
|
-
*/
|
|
16
|
-
export type OpenRouterChatParams = (ChatCompletionCreateParamsNonStreaming | ChatCompletionCreateParamsStreaming) & {
|
|
17
|
-
top_k?: number;
|
|
18
|
-
min_p?: number;
|
|
19
|
-
transforms?: string[];
|
|
20
|
-
models?: string[];
|
|
21
|
-
route?: "fallback";
|
|
22
|
-
provider?: Record<string, unknown>;
|
|
23
|
-
};
|
|
24
|
-
declare class OpenRouterProvider {
|
|
25
|
-
private client?;
|
|
26
|
-
status: "unconfigured" | "initializing" | "ready" | "error";
|
|
27
|
-
private initializationError;
|
|
28
|
-
constructor();
|
|
29
|
-
initialize(options?: OpenRouterClientOptions): void;
|
|
30
|
-
private checkReady;
|
|
31
|
-
chatCompletion(params: OpenRouterChatParams, context: RequestContext): Promise<ChatCompletion | Stream<ChatCompletionChunk>>;
|
|
32
|
-
chatCompletionStream(params: OpenRouterChatParams, context: RequestContext): Promise<AsyncIterable<ChatCompletionChunk>>;
|
|
33
|
-
}
|
|
34
|
-
declare const openRouterProviderInstance: OpenRouterProvider;
|
|
35
|
-
export { openRouterProviderInstance as openRouterProvider, OpenRouterProvider };
|
|
36
|
-
//# sourceMappingURL=openRouterProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openRouterProvider.d.ts","sourceRoot":"","sources":["../../../src/services/llm-providers/openRouterProvider.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,sCAAsC,EACtC,mCAAmC,EACpC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAK1C,OAAO,EACL,cAAc,EAEf,MAAM,oCAAoC,CAAC;AAO5C;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAC/B,sCAAsC,GACtC,mCAAmC,CACtC,GAAG;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AA+KF,cAAM,kBAAkB;IACtB,OAAO,CAAC,MAAM,CAAC,CAAS;IACjB,MAAM,EAAE,cAAc,GAAG,cAAc,GAAG,OAAO,GAAG,OAAO,CAAC;IACnE,OAAO,CAAC,mBAAmB,CAAsB;;IAM1C,UAAU,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,IAAI;IAkD1D,OAAO,CAAC,UAAU;IAgBL,cAAc,CACzB,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,cAAc,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAmB3C,oBAAoB,CAC/B,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;CAuB/C;AAED,QAAA,MAAM,0BAA0B,oBAA2B,CAAC;AAE5D,OAAO,EAAE,0BAA0B,IAAI,kBAAkB,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Provides a service class (`OpenRouterProvider`) for interacting with the
|
|
3
|
-
* OpenRouter API. This file implements the "handler" pattern internally, where the
|
|
4
|
-
* OpenRouterProvider class manages state and error handling, while private logic functions
|
|
5
|
-
* execute the core API interactions and throw structured errors.
|
|
6
|
-
* @module src/services/llm-providers/openRouterProvider
|
|
7
|
-
*/
|
|
8
|
-
import OpenAI from "openai";
|
|
9
|
-
import { config } from "../../config/index.js";
|
|
10
|
-
import { JsonRpcErrorCode, McpError } from "../../types-global/errors.js";
|
|
11
|
-
import { ErrorHandler } from "../../utils/internal/errorHandler.js";
|
|
12
|
-
import { logger } from "../../utils/internal/logger.js";
|
|
13
|
-
import { requestContextService, } from "../../utils/internal/requestContext.js";
|
|
14
|
-
import { rateLimiter } from "../../utils/security/rateLimiter.js";
|
|
15
|
-
import { sanitization } from "../../utils/security/sanitization.js";
|
|
16
|
-
// #region Internal Logic Functions (Throwing Errors)
|
|
17
|
-
/**
|
|
18
|
-
* Prepares parameters for the OpenRouter API call, separating standard
|
|
19
|
-
* and extra parameters and applying defaults.
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
function _prepareApiParameters(params) {
|
|
23
|
-
const effectiveModelId = params.model || config.llmDefaultModel;
|
|
24
|
-
const standardParams = {
|
|
25
|
-
model: effectiveModelId,
|
|
26
|
-
messages: params.messages,
|
|
27
|
-
...(params.temperature !== undefined ||
|
|
28
|
-
config.llmDefaultTemperature !== undefined
|
|
29
|
-
? { temperature: params.temperature ?? config.llmDefaultTemperature }
|
|
30
|
-
: {}),
|
|
31
|
-
...(params.top_p !== undefined || config.llmDefaultTopP !== undefined
|
|
32
|
-
? { top_p: params.top_p ?? config.llmDefaultTopP }
|
|
33
|
-
: {}),
|
|
34
|
-
...(params.presence_penalty !== undefined
|
|
35
|
-
? { presence_penalty: params.presence_penalty }
|
|
36
|
-
: {}),
|
|
37
|
-
...(params.stream !== undefined && { stream: params.stream }),
|
|
38
|
-
...(params.tools !== undefined && { tools: params.tools }),
|
|
39
|
-
...(params.tool_choice !== undefined && {
|
|
40
|
-
tool_choice: params.tool_choice,
|
|
41
|
-
}),
|
|
42
|
-
...(params.response_format !== undefined && {
|
|
43
|
-
response_format: params.response_format,
|
|
44
|
-
}),
|
|
45
|
-
...(params.stop !== undefined && { stop: params.stop }),
|
|
46
|
-
...(params.seed !== undefined && { seed: params.seed }),
|
|
47
|
-
...(params.frequency_penalty !== undefined
|
|
48
|
-
? { frequency_penalty: params.frequency_penalty }
|
|
49
|
-
: {}),
|
|
50
|
-
...(params.logit_bias !== undefined && { logit_bias: params.logit_bias }),
|
|
51
|
-
};
|
|
52
|
-
const extraBody = {};
|
|
53
|
-
const standardKeys = new Set(Object.keys(standardParams));
|
|
54
|
-
standardKeys.add("messages");
|
|
55
|
-
for (const key in params) {
|
|
56
|
-
if (Object.prototype.hasOwnProperty.call(params, key) &&
|
|
57
|
-
!standardKeys.has(key) &&
|
|
58
|
-
key !== "max_tokens") {
|
|
59
|
-
extraBody[key] = params[key];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (extraBody.top_k === undefined && config.llmDefaultTopK !== undefined) {
|
|
63
|
-
extraBody.top_k = config.llmDefaultTopK;
|
|
64
|
-
}
|
|
65
|
-
if (extraBody.min_p === undefined && config.llmDefaultMinP !== undefined) {
|
|
66
|
-
extraBody.min_p = config.llmDefaultMinP;
|
|
67
|
-
}
|
|
68
|
-
if (extraBody.provider &&
|
|
69
|
-
typeof extraBody.provider === "object" &&
|
|
70
|
-
extraBody.provider !== null) {
|
|
71
|
-
const provider = extraBody.provider;
|
|
72
|
-
if (!provider.sort) {
|
|
73
|
-
provider.sort = "throughput";
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
else if (extraBody.provider === undefined) {
|
|
77
|
-
extraBody.provider = { sort: "throughput" };
|
|
78
|
-
}
|
|
79
|
-
const modelsRequiringMaxCompletionTokens = ["openai/o1", "openai/gpt-4.1"];
|
|
80
|
-
const needsMaxCompletionTokens = modelsRequiringMaxCompletionTokens.some((modelPrefix) => effectiveModelId.startsWith(modelPrefix));
|
|
81
|
-
const effectiveMaxTokensValue = params.max_tokens ?? config.llmDefaultMaxTokens;
|
|
82
|
-
if (effectiveMaxTokensValue !== undefined) {
|
|
83
|
-
if (needsMaxCompletionTokens) {
|
|
84
|
-
extraBody.max_completion_tokens = effectiveMaxTokensValue;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
standardParams.max_tokens = effectiveMaxTokensValue;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return { standardParams, extraBody };
|
|
91
|
-
}
|
|
92
|
-
async function _openRouterChatCompletionLogic(client, params, context) {
|
|
93
|
-
const isStreaming = params.stream === true;
|
|
94
|
-
const { standardParams, extraBody } = _prepareApiParameters(params);
|
|
95
|
-
const apiParams = { ...standardParams };
|
|
96
|
-
if (Object.keys(extraBody).length > 0) {
|
|
97
|
-
apiParams.extra_body = extraBody;
|
|
98
|
-
}
|
|
99
|
-
logger.logInteraction("OpenRouterRequest", {
|
|
100
|
-
context,
|
|
101
|
-
request: apiParams,
|
|
102
|
-
});
|
|
103
|
-
try {
|
|
104
|
-
if (isStreaming) {
|
|
105
|
-
return await client.chat.completions.create(apiParams);
|
|
106
|
-
}
|
|
107
|
-
const response = await client.chat.completions.create(apiParams);
|
|
108
|
-
logger.logInteraction("OpenRouterResponse", {
|
|
109
|
-
context,
|
|
110
|
-
response,
|
|
111
|
-
streaming: false,
|
|
112
|
-
});
|
|
113
|
-
return response;
|
|
114
|
-
}
|
|
115
|
-
catch (e) {
|
|
116
|
-
const error = e;
|
|
117
|
-
logger.logInteraction("OpenRouterError", {
|
|
118
|
-
context,
|
|
119
|
-
error: {
|
|
120
|
-
message: error.message,
|
|
121
|
-
stack: error.stack,
|
|
122
|
-
status: error.status,
|
|
123
|
-
cause: error.cause,
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
const errorDetails = {
|
|
127
|
-
providerStatus: error.status,
|
|
128
|
-
providerMessage: error.message,
|
|
129
|
-
cause: error?.cause,
|
|
130
|
-
};
|
|
131
|
-
if (error.status === 401) {
|
|
132
|
-
throw new McpError(JsonRpcErrorCode.Unauthorized, `OpenRouter authentication failed: ${error.message}`, errorDetails);
|
|
133
|
-
}
|
|
134
|
-
else if (error.status === 429) {
|
|
135
|
-
throw new McpError(JsonRpcErrorCode.RateLimited, `OpenRouter rate limit exceeded: ${error.message}`, errorDetails);
|
|
136
|
-
}
|
|
137
|
-
else if (error.status === 402) {
|
|
138
|
-
throw new McpError(JsonRpcErrorCode.Forbidden, `OpenRouter insufficient credits or payment required: ${error.message}`, errorDetails);
|
|
139
|
-
}
|
|
140
|
-
throw new McpError(JsonRpcErrorCode.InternalError, `OpenRouter API error (${error.status || "unknown status"}): ${error.message}`, errorDetails);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
class OpenRouterProvider {
|
|
144
|
-
client;
|
|
145
|
-
status;
|
|
146
|
-
initializationError = null;
|
|
147
|
-
constructor() {
|
|
148
|
-
this.status = "unconfigured";
|
|
149
|
-
}
|
|
150
|
-
initialize(options) {
|
|
151
|
-
const opContext = requestContextService.createRequestContext({
|
|
152
|
-
operation: "OpenRouterProvider.initialize",
|
|
153
|
-
});
|
|
154
|
-
this.status = "initializing";
|
|
155
|
-
const apiKey = options?.apiKey !== undefined ? options.apiKey : config.openrouterApiKey;
|
|
156
|
-
if (!apiKey) {
|
|
157
|
-
this.status = "unconfigured";
|
|
158
|
-
this.initializationError = new McpError(JsonRpcErrorCode.ConfigurationError, "OpenRouter API key is not configured.");
|
|
159
|
-
logger.error({
|
|
160
|
-
...opContext,
|
|
161
|
-
error: this.initializationError,
|
|
162
|
-
}, this.initializationError.message);
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
try {
|
|
166
|
-
this.client = new OpenAI({
|
|
167
|
-
baseURL: options?.baseURL || "https://openrouter.ai/api/v1",
|
|
168
|
-
apiKey,
|
|
169
|
-
defaultHeaders: {
|
|
170
|
-
"HTTP-Referer": options?.siteUrl || config.openrouterAppUrl,
|
|
171
|
-
"X-Title": options?.siteName || config.openrouterAppName,
|
|
172
|
-
},
|
|
173
|
-
maxRetries: 0,
|
|
174
|
-
});
|
|
175
|
-
this.status = "ready";
|
|
176
|
-
logger.info(opContext, "OpenRouter Service Initialized and Ready");
|
|
177
|
-
}
|
|
178
|
-
catch (e) {
|
|
179
|
-
const error = e;
|
|
180
|
-
this.status = "error";
|
|
181
|
-
this.initializationError = error;
|
|
182
|
-
logger.error({
|
|
183
|
-
...opContext,
|
|
184
|
-
error,
|
|
185
|
-
}, "Failed to initialize OpenRouter client");
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
checkReady(operation, context) {
|
|
189
|
-
if (this.status !== "ready" || !this.client) {
|
|
190
|
-
const message = `OpenRouter service is not available (status: ${this.status}).`;
|
|
191
|
-
logger.error({
|
|
192
|
-
...context,
|
|
193
|
-
status: this.status,
|
|
194
|
-
}, `[${operation}] ${message}`);
|
|
195
|
-
throw new McpError(JsonRpcErrorCode.ServiceUnavailable, message, {
|
|
196
|
-
cause: this.initializationError,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
async chatCompletion(params, context) {
|
|
201
|
-
const operation = "OpenRouterProvider.chatCompletion";
|
|
202
|
-
const sanitizedParams = sanitization.sanitizeForLogging(params);
|
|
203
|
-
return await ErrorHandler.tryCatch(async () => {
|
|
204
|
-
this.checkReady(operation, context);
|
|
205
|
-
const rateLimitKey = context.requestId || "openrouter_default_key";
|
|
206
|
-
rateLimiter.check(rateLimitKey, context);
|
|
207
|
-
return await _openRouterChatCompletionLogic(this.client, params, context);
|
|
208
|
-
}, { operation, context, input: sanitizedParams });
|
|
209
|
-
}
|
|
210
|
-
async chatCompletionStream(params, context) {
|
|
211
|
-
const streamParams = { ...params, stream: true };
|
|
212
|
-
const response = await this.chatCompletion(streamParams, context);
|
|
213
|
-
const responseStream = response;
|
|
214
|
-
async function* loggingStream() {
|
|
215
|
-
const chunks = [];
|
|
216
|
-
try {
|
|
217
|
-
for await (const chunk of responseStream) {
|
|
218
|
-
chunks.push(chunk);
|
|
219
|
-
yield chunk;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
finally {
|
|
223
|
-
logger.logInteraction("OpenRouterResponse", {
|
|
224
|
-
context,
|
|
225
|
-
response: chunks,
|
|
226
|
-
streaming: true,
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return loggingStream();
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
const openRouterProviderInstance = new OpenRouterProvider();
|
|
234
|
-
export { openRouterProviderInstance as openRouterProvider, OpenRouterProvider };
|
|
235
|
-
//# sourceMappingURL=openRouterProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openRouterProvider.js","sourceRoot":"","sources":["../../../src/services/llm-providers/openRouterProvider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAQ5B,OAAO,EAAE,MAAM,EAAE,MA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