@infersec/conduit 1.94.0 → 1.96.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.
@@ -1,8 +1,18 @@
1
- import type { ToolConfigurationOverrides } from "../toolConnection/configuration.js";
1
+ import { type ToolConfigurationOverrides } from "../toolConnection/configuration.js";
2
2
  export interface ToolConnectCommandOptions {
3
+ allow?: string;
3
4
  apiUrl?: string;
5
+ database?: string;
6
+ host?: string;
4
7
  key?: string;
8
+ maxRows?: string;
9
+ password?: string;
5
10
  path?: string;
11
+ poolMax?: string;
12
+ port?: string;
13
+ queryTimeoutMs?: string;
6
14
  readOnly?: boolean;
15
+ url?: string;
16
+ user?: string;
7
17
  }
8
18
  export declare function buildToolConfigurationOverrides(toolID: string, options: ToolConnectCommandOptions): ToolConfigurationOverrides;
@@ -0,0 +1 @@
1
+ export declare const SERVED_MODEL_NAME = "default";
@@ -20,6 +20,7 @@ export declare class ModelManager extends EventEmitter<ModelManagerEvents> {
20
20
  protected readonly logger: Logger;
21
21
  private engineProcess;
22
22
  private healthPollInterval;
23
+ private lastEngineError;
23
24
  private lifecycleState;
24
25
  private stopRequested;
25
26
  protected readonly modelsDirectory: string;
@@ -51,6 +52,7 @@ export declare class ModelManager extends EventEmitter<ModelManagerEvents> {
51
52
  private get lockFilePath();
52
53
  private acquireDownloadLock;
53
54
  private getLockAge;
55
+ private recordEngineError;
54
56
  private releaseDownloadLock;
55
57
  private waitForDownloadLock;
56
58
  private bindEngineProcessEvents;
@@ -0,0 +1 @@
1
+ export declare function normalizeEngineError(input: string): string;
@@ -1,9 +1,13 @@
1
1
  import type { ULID } from "@infersec/definitions";
2
2
  import type { Logger } from "@infersec/logger";
3
+ import type { MysqlConnectionConfig } from "./configuration.js";
3
4
  export interface ToolConnectionOptions {
4
5
  apiKey: string;
5
6
  apiURL: string;
6
7
  logger: Logger;
8
+ maxRows: number;
9
+ mysql: MysqlConnectionConfig | null;
10
+ mysqlAllow: string[];
7
11
  readOnly: boolean;
8
12
  rootPath: string;
9
13
  toolID: ULID;
@@ -16,5 +20,7 @@ export declare class ToolConnection {
16
20
  private options;
17
21
  constructor(options: ToolConnectionOptions);
18
22
  start(): Promise<void>;
23
+ private createToolServer;
24
+ private createMysqlToolServer;
19
25
  stop(): Promise<void>;
20
26
  }
@@ -1,7 +1,20 @@
1
1
  import { ULID } from "@infersec/definitions";
2
+ export interface MysqlConnectionConfig {
3
+ connectionLimit: number;
4
+ database?: string;
5
+ host?: string;
6
+ password?: string;
7
+ port?: number;
8
+ queryTimeoutMs: number;
9
+ url?: string;
10
+ user?: string;
11
+ }
2
12
  export interface ToolConfiguration {
3
13
  apiKey: string;
4
14
  apiURL: string;
15
+ maxRows: number;
16
+ mysql: MysqlConnectionConfig | null;
17
+ mysqlAllow: string[];
5
18
  readOnly: boolean;
6
19
  rootPath: string;
7
20
  toolID: ULID;
@@ -9,10 +22,14 @@ export interface ToolConfiguration {
9
22
  export interface ToolConfigurationOverrides {
10
23
  apiKey?: string;
11
24
  apiURL?: string;
25
+ maxRows?: number;
26
+ mysql?: MysqlConnectionConfig;
27
+ mysqlAllow?: string[];
12
28
  readOnly?: boolean;
13
29
  rootPath?: string;
14
30
  toolID?: ULID;
15
31
  }
32
+ export declare function parseAllowList(raw: string): string[];
16
33
  export declare function getToolConfiguration({ overrides }?: {
17
34
  overrides?: ToolConfigurationOverrides;
18
35
  }): ToolConfiguration;
@@ -0,0 +1,37 @@
1
+ import { Logger } from "@infersec/logger";
2
+ import { z } from "zod";
3
+ import type { MCPContent } from "./shared.js";
4
+ interface JSONRPCRequest {
5
+ id?: number;
6
+ jsonrpc: "2.0";
7
+ method: string;
8
+ params?: Record<string, unknown>;
9
+ }
10
+ interface JSONRPCResponse {
11
+ error?: {
12
+ code: number;
13
+ message: string;
14
+ };
15
+ id: number | null;
16
+ jsonrpc: "2.0";
17
+ result?: unknown;
18
+ }
19
+ export interface LocalToolServer {
20
+ close: () => Promise<void>;
21
+ handleRequest: (request: JSONRPCRequest) => Promise<JSONRPCResponse>;
22
+ }
23
+ export interface LocalOperation<Context> {
24
+ handler: (args: Record<string, unknown>, ctx: Context) => Promise<MCPContent>;
25
+ inputSchema: z.ZodRawShape;
26
+ metadata: {
27
+ description: string;
28
+ name: string;
29
+ };
30
+ }
31
+ export declare function createLocalToolServer<Context>({ context, logger, name, operations }: {
32
+ context: Context;
33
+ logger: Logger;
34
+ name: string;
35
+ operations: Array<LocalOperation<Context>>;
36
+ }): LocalToolServer;
37
+ export {};
@@ -1,11 +1,5 @@
1
1
  import { z } from "zod";
2
- export type MCPContent = {
3
- content: Array<{
4
- text: string;
5
- type: "text";
6
- }>;
7
- isError?: boolean;
8
- };
2
+ import { type MCPContent } from "../shared.js";
9
3
  export interface OperationContext {
10
4
  basePath: string;
11
5
  }
@@ -1,26 +1,8 @@
1
1
  import { Logger } from "@infersec/logger";
2
- interface JSONRPCRequest {
3
- id?: number;
4
- jsonrpc: "2.0";
5
- method: string;
6
- params?: Record<string, unknown>;
7
- }
8
- interface JSONRPCResponse {
9
- error?: {
10
- code: number;
11
- message: string;
12
- };
13
- id: number | null;
14
- jsonrpc: "2.0";
15
- result?: unknown;
16
- }
17
- export interface LocalToolServer {
18
- close: () => Promise<void>;
19
- handleRequest: (request: JSONRPCRequest) => Promise<JSONRPCResponse>;
20
- }
2
+ import { type LocalToolServer } from "./createLocalToolServer.js";
3
+ export type { LocalToolServer } from "./createLocalToolServer.js";
21
4
  export declare function createFilesystemToolServer({ basePath, logger, readOnly }: {
22
5
  basePath: string;
23
6
  logger: Logger;
24
7
  readOnly: boolean;
25
8
  }): LocalToolServer;
26
- export {};
@@ -0,0 +1,9 @@
1
+ export type MCPContent = {
2
+ content: Array<{
3
+ text: string;
4
+ type: "text";
5
+ }>;
6
+ isError?: boolean;
7
+ };
8
+ export declare function textResult(text: string, isError?: boolean): MCPContent;
9
+ export declare function jsonResult(data: unknown, isError?: boolean): MCPContent;
@@ -0,0 +1,12 @@
1
+ import type { SqlAdapter } from "../types.js";
2
+ export interface MysqlAdapterConfig {
3
+ connectionLimit: number;
4
+ database?: string;
5
+ host?: string;
6
+ password?: string;
7
+ port?: number;
8
+ queryTimeoutMs: number;
9
+ url?: string;
10
+ user?: string;
11
+ }
12
+ export declare function createMysqlAdapter(config: MysqlAdapterConfig): Promise<SqlAdapter>;
@@ -0,0 +1,66 @@
1
+ import { z } from "zod";
2
+ import { type MCPContent } from "../shared.js";
3
+ import type { SqlAdapter } from "./types.js";
4
+ export interface OperationContext {
5
+ adapter: SqlAdapter;
6
+ maxRows: number;
7
+ }
8
+ export type OperationHandler = (args: Record<string, unknown>, ctx: OperationContext) => Promise<MCPContent>;
9
+ export interface SqlOperationDefinition {
10
+ handler: OperationHandler;
11
+ inputSchema: z.ZodRawShape;
12
+ isWrite: boolean;
13
+ metadata: {
14
+ description: string;
15
+ name: string;
16
+ };
17
+ }
18
+ export declare const getTablesSchema: {
19
+ database: z.ZodOptional<z.ZodString>;
20
+ };
21
+ export declare const getTableSchemaSchema: {
22
+ database: z.ZodOptional<z.ZodString>;
23
+ table: z.ZodString;
24
+ };
25
+ export declare const selectSchema: {
26
+ columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
27
+ database: z.ZodOptional<z.ZodString>;
28
+ limit: z.ZodOptional<z.ZodNumber>;
29
+ order: z.ZodOptional<z.ZodArray<z.ZodObject<{
30
+ column: z.ZodString;
31
+ direction: z.ZodOptional<z.ZodEnum<{
32
+ asc: "asc";
33
+ desc: "desc";
34
+ }>>;
35
+ }, z.core.$strip>>>;
36
+ table: z.ZodString;
37
+ where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
38
+ };
39
+ export declare const insertSchema: {
40
+ database: z.ZodOptional<z.ZodString>;
41
+ table: z.ZodString;
42
+ values: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>]>;
43
+ };
44
+ export declare const updateSchema: {
45
+ database: z.ZodOptional<z.ZodString>;
46
+ set: z.ZodRecord<z.ZodString, z.ZodUnknown>;
47
+ table: z.ZodString;
48
+ where: z.ZodRecord<z.ZodString, z.ZodUnknown>;
49
+ };
50
+ export declare const deleteSchema: {
51
+ database: z.ZodOptional<z.ZodString>;
52
+ table: z.ZodString;
53
+ where: z.ZodRecord<z.ZodString, z.ZodUnknown>;
54
+ };
55
+ export declare const truncateSchema: {
56
+ database: z.ZodOptional<z.ZodString>;
57
+ table: z.ZodString;
58
+ };
59
+ export declare const sqlSchema: {
60
+ params: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
61
+ query: z.ZodString;
62
+ };
63
+ export declare const SQL_OPERATIONS: Array<SqlOperationDefinition>;
64
+ export declare const WRITE_OPERATION_NAMES: string[];
65
+ export declare function resolveAllowedOperations(allow: string[] | undefined): string[];
66
+ export declare function selectExposedOperations(allowed: string[]): Array<SqlOperationDefinition>;
@@ -0,0 +1,11 @@
1
+ import { Logger } from "@infersec/logger";
2
+ import { type LocalToolServer } from "../createLocalToolServer.js";
3
+ import type { SqlAdapter } from "./types.js";
4
+ export interface SqlToolServerOptions {
5
+ adapter: SqlAdapter;
6
+ allow: string[];
7
+ logger: Logger;
8
+ maxRows: number;
9
+ name: string;
10
+ }
11
+ export declare function createSqlToolServer({ adapter, allow, logger, maxRows, name }: SqlToolServerOptions): LocalToolServer;
@@ -0,0 +1,22 @@
1
+ export interface ColumnInfo {
2
+ defaultValue: string | null;
3
+ extra: string;
4
+ key: string;
5
+ name: string;
6
+ nullable: boolean;
7
+ type: string;
8
+ }
9
+ export interface QueryResult {
10
+ affectedRows: number;
11
+ insertId: number | string | null;
12
+ rows: Array<Record<string, unknown>>;
13
+ }
14
+ export interface SqlAdapter {
15
+ readonly name: string;
16
+ close(): Promise<void>;
17
+ describeTable(database: string | undefined, table: string): Promise<ColumnInfo[]>;
18
+ listTables(database?: string): Promise<string[]>;
19
+ query(sql: string, params?: unknown[]): Promise<QueryResult>;
20
+ quoteIdentifier(name: string): string;
21
+ }
22
+ export declare function validateIdentifier(name: string): string;
@@ -0,0 +1,19 @@
1
+ export type Primitive = boolean | null | number | string;
2
+ export interface ConditionOperators {
3
+ eq?: Primitive;
4
+ gt?: Primitive;
5
+ gte?: Primitive;
6
+ in?: Primitive[];
7
+ isNull?: boolean;
8
+ like?: string;
9
+ lt?: Primitive;
10
+ lte?: Primitive;
11
+ ne?: Primitive;
12
+ }
13
+ export type Condition = ConditionOperators | Primitive;
14
+ export type WhereInput = Record<string, Condition>;
15
+ export interface BuiltClause {
16
+ clause: string;
17
+ params: unknown[];
18
+ }
19
+ export declare function buildWhereClause(quote: (name: string) => string, where: WhereInput | undefined): BuiltClause;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@infersec/conduit",
3
3
  "description": "End user conduit agent for connecting local LLMs to the cloud.",
4
- "version": "1.94.0",
4
+ "version": "1.96.0",
5
5
  "bin": {
6
6
  "infersec-conduit": "./dist/cli.js"
7
7
  },
@@ -67,6 +67,7 @@
67
67
  "express": "^4.21.2",
68
68
  "express-promise-router": "^4.1.1",
69
69
  "glob": "^11.0.3",
70
+ "mysql2": "^3.23.3",
70
71
  "supertest": "^7.1.4",
71
72
  "systeminformation": "^5.30.3",
72
73
  "undici": "^7.13.0",