@toolplex/client 0.1.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/LICENSE +98 -0
- package/README.md +112 -0
- package/dist/mcp-server/clientContext.d.ts +35 -0
- package/dist/mcp-server/clientContext.js +107 -0
- package/dist/mcp-server/index.d.ts +1 -0
- package/dist/mcp-server/index.js +22 -0
- package/dist/mcp-server/logging/telemetryLogger.d.ts +18 -0
- package/dist/mcp-server/logging/telemetryLogger.js +54 -0
- package/dist/mcp-server/policy/callToolObserver.d.ts +9 -0
- package/dist/mcp-server/policy/callToolObserver.js +25 -0
- package/dist/mcp-server/policy/feedbackPolicy.d.ts +27 -0
- package/dist/mcp-server/policy/feedbackPolicy.js +39 -0
- package/dist/mcp-server/policy/installObserver.d.ts +11 -0
- package/dist/mcp-server/policy/installObserver.js +35 -0
- package/dist/mcp-server/policy/playbookPolicy.d.ts +29 -0
- package/dist/mcp-server/policy/playbookPolicy.js +81 -0
- package/dist/mcp-server/policy/policyEnforcer.d.ts +57 -0
- package/dist/mcp-server/policy/policyEnforcer.js +105 -0
- package/dist/mcp-server/policy/serverPolicy.d.ts +39 -0
- package/dist/mcp-server/policy/serverPolicy.js +61 -0
- package/dist/mcp-server/promptsCache.d.ts +25 -0
- package/dist/mcp-server/promptsCache.js +51 -0
- package/dist/mcp-server/registry.d.ts +34 -0
- package/dist/mcp-server/registry.js +109 -0
- package/dist/mcp-server/serversCache.d.ts +53 -0
- package/dist/mcp-server/serversCache.js +100 -0
- package/dist/mcp-server/staticPrompts.d.ts +6 -0
- package/dist/mcp-server/staticPrompts.js +6 -0
- package/dist/mcp-server/toolDefinitionsCache.d.ts +33 -0
- package/dist/mcp-server/toolDefinitionsCache.js +67 -0
- package/dist/mcp-server/toolHandlers/callToolHandler.d.ts +3 -0
- package/dist/mcp-server/toolHandlers/callToolHandler.js +79 -0
- package/dist/mcp-server/toolHandlers/getServerConfigHandler.d.ts +3 -0
- package/dist/mcp-server/toolHandlers/getServerConfigHandler.js +69 -0
- package/dist/mcp-server/toolHandlers/initHandler.d.ts +3 -0
- package/dist/mcp-server/toolHandlers/initHandler.js +117 -0
- package/dist/mcp-server/toolHandlers/installServerHandler.d.ts +3 -0
- package/dist/mcp-server/toolHandlers/installServerHandler.js +151 -0
- package/dist/mcp-server/toolHandlers/listServersHandler.d.ts +2 -0
- package/dist/mcp-server/toolHandlers/listServersHandler.js +81 -0
- package/dist/mcp-server/toolHandlers/listToolsHandler.d.ts +3 -0
- package/dist/mcp-server/toolHandlers/listToolsHandler.js +112 -0
- package/dist/mcp-server/toolHandlers/logPlaybookUsageHandler.d.ts +3 -0
- package/dist/mcp-server/toolHandlers/logPlaybookUsageHandler.js +65 -0
- package/dist/mcp-server/toolHandlers/lookupEntityHandler.d.ts +3 -0
- package/dist/mcp-server/toolHandlers/lookupEntityHandler.js +112 -0
- package/dist/mcp-server/toolHandlers/savePlaybookHandler.d.ts +3 -0
- package/dist/mcp-server/toolHandlers/savePlaybookHandler.js +65 -0
- package/dist/mcp-server/toolHandlers/searchHandler.d.ts +3 -0
- package/dist/mcp-server/toolHandlers/searchHandler.js +114 -0
- package/dist/mcp-server/toolHandlers/serverManagerUtils.d.ts +2 -0
- package/dist/mcp-server/toolHandlers/serverManagerUtils.js +20 -0
- package/dist/mcp-server/toolHandlers/submitFeedbackHandler.d.ts +3 -0
- package/dist/mcp-server/toolHandlers/submitFeedbackHandler.js +70 -0
- package/dist/mcp-server/toolHandlers/uninstallServerHandler.d.ts +3 -0
- package/dist/mcp-server/toolHandlers/uninstallServerHandler.js +83 -0
- package/dist/mcp-server/toolplexApi/service.d.ts +32 -0
- package/dist/mcp-server/toolplexApi/service.js +222 -0
- package/dist/mcp-server/toolplexApi/types.d.ts +124 -0
- package/dist/mcp-server/toolplexApi/types.js +1 -0
- package/dist/mcp-server/toolplexServer.d.ts +3 -0
- package/dist/mcp-server/toolplexServer.js +249 -0
- package/dist/mcp-server/tools.d.ts +2 -0
- package/dist/mcp-server/tools.js +13 -0
- package/dist/mcp-server/utils/initServerManagers.d.ts +6 -0
- package/dist/mcp-server/utils/initServerManagers.js +31 -0
- package/dist/mcp-server/utils/resultAnnotators.d.ts +23 -0
- package/dist/mcp-server/utils/resultAnnotators.js +50 -0
- package/dist/mcp-server/utils/runtimeCheck.d.ts +4 -0
- package/dist/mcp-server/utils/runtimeCheck.js +30 -0
- package/dist/server-manager/index.d.ts +1 -0
- package/dist/server-manager/index.js +8 -0
- package/dist/server-manager/serverManager.d.ts +37 -0
- package/dist/server-manager/serverManager.js +419 -0
- package/dist/server-manager/stdioServer.d.ts +9 -0
- package/dist/server-manager/stdioServer.js +136 -0
- package/dist/server-manager/stdioTransportProtocol.d.ts +31 -0
- package/dist/server-manager/stdioTransportProtocol.js +67 -0
- package/dist/shared/enhancedPath.d.ts +7 -0
- package/dist/shared/enhancedPath.js +52 -0
- package/dist/shared/fileLogger.d.ts +13 -0
- package/dist/shared/fileLogger.js +66 -0
- package/dist/shared/mcpServerTypes.d.ts +398 -0
- package/dist/shared/mcpServerTypes.js +148 -0
- package/dist/shared/serverManagerTypes.d.ts +179 -0
- package/dist/shared/serverManagerTypes.js +73 -0
- package/dist/shared/stdioServerManagerClient.d.ts +12 -0
- package/dist/shared/stdioServerManagerClient.js +96 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
import { glob } from 'glob';
|
|
5
|
+
/**
|
|
6
|
+
* Returns an enhanced PATH string by prepending common binary directories
|
|
7
|
+
* across platforms (Linux, macOS, Windows).
|
|
8
|
+
*
|
|
9
|
+
* Ensures no duplicates and checks for existence.
|
|
10
|
+
*/
|
|
11
|
+
export function getEnhancedPath() {
|
|
12
|
+
const home = homedir();
|
|
13
|
+
const basePaths = (process.env.PATH || '').split(path.delimiter);
|
|
14
|
+
const extraPaths = getDefaultExtraPaths(home);
|
|
15
|
+
const seen = new Set(basePaths);
|
|
16
|
+
const allPaths = [...basePaths];
|
|
17
|
+
for (const extraPath of extraPaths) {
|
|
18
|
+
if (extraPath.includes('*')) {
|
|
19
|
+
const matches = glob.sync(extraPath);
|
|
20
|
+
for (const match of matches) {
|
|
21
|
+
if (existsSync(match) && !seen.has(match)) {
|
|
22
|
+
seen.add(match);
|
|
23
|
+
allPaths.unshift(match);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
if (existsSync(extraPath) && !seen.has(extraPath)) {
|
|
29
|
+
seen.add(extraPath);
|
|
30
|
+
allPaths.unshift(extraPath);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return allPaths.join(path.delimiter);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns platform-specific extra binary paths.
|
|
38
|
+
*/
|
|
39
|
+
function getDefaultExtraPaths(home) {
|
|
40
|
+
const isWindows = process.platform === 'win32';
|
|
41
|
+
return isWindows
|
|
42
|
+
? [
|
|
43
|
+
path.join(home, 'AppData/Local/Programs/Python/Python3*/Scripts'),
|
|
44
|
+
path.join(home, 'AppData/Roaming/npm'),
|
|
45
|
+
]
|
|
46
|
+
: [
|
|
47
|
+
path.join(home, '.local/bin'),
|
|
48
|
+
path.join(home, '.cargo/bin'),
|
|
49
|
+
'/usr/local/bin',
|
|
50
|
+
'/opt/homebrew/bin',
|
|
51
|
+
];
|
|
52
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const logDir: string;
|
|
2
|
+
export declare class FileLogger {
|
|
3
|
+
private static logger;
|
|
4
|
+
private static transport;
|
|
5
|
+
private static processName;
|
|
6
|
+
static initialize(processName: string): void;
|
|
7
|
+
private static log;
|
|
8
|
+
static info(message: string): void;
|
|
9
|
+
static warn(message: string): void;
|
|
10
|
+
static error(message: string): void;
|
|
11
|
+
static debug(message: string): void;
|
|
12
|
+
static flush(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import envPaths from 'env-paths';
|
|
3
|
+
import winston from 'winston';
|
|
4
|
+
import callsite from 'callsite';
|
|
5
|
+
import DailyRotateFile from 'winston-daily-rotate-file';
|
|
6
|
+
const paths = envPaths('ToolPlex', { suffix: '' });
|
|
7
|
+
export const logDir = path.join(paths.log);
|
|
8
|
+
function getCallingModule() {
|
|
9
|
+
const stack = callsite();
|
|
10
|
+
for (let i = 2; i < stack.length; i++) {
|
|
11
|
+
const fileName = stack[i].getFileName();
|
|
12
|
+
if (fileName &&
|
|
13
|
+
!fileName.includes('node_modules') &&
|
|
14
|
+
!fileName.includes('fileLogger') &&
|
|
15
|
+
!fileName.includes('callsite')) {
|
|
16
|
+
return path.basename(fileName, path.extname(fileName));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return 'unknown';
|
|
20
|
+
}
|
|
21
|
+
export class FileLogger {
|
|
22
|
+
static initialize(processName) {
|
|
23
|
+
if (this.logger)
|
|
24
|
+
return;
|
|
25
|
+
this.processName = processName;
|
|
26
|
+
const logLevel = process.env.LOG_LEVEL || 'info';
|
|
27
|
+
this.transport = new DailyRotateFile({
|
|
28
|
+
dirname: logDir,
|
|
29
|
+
filename: `ToolPlex-${processName}-%DATE%.log`,
|
|
30
|
+
datePattern: 'YYYY-MM-DD',
|
|
31
|
+
maxFiles: '7d',
|
|
32
|
+
zippedArchive: false,
|
|
33
|
+
level: logLevel,
|
|
34
|
+
});
|
|
35
|
+
this.logger = winston.createLogger({
|
|
36
|
+
level: logLevel,
|
|
37
|
+
format: winston.format.combine(winston.format.timestamp(), winston.format.printf(({ level, message, timestamp, module }) => {
|
|
38
|
+
return `${timestamp} [${level.toUpperCase()}] ${module || 'unknown'} - ${message}`;
|
|
39
|
+
})),
|
|
40
|
+
defaultMeta: {},
|
|
41
|
+
transports: [this.transport],
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
static log(level, message) {
|
|
45
|
+
const module = getCallingModule();
|
|
46
|
+
this.logger.log({ level, message, module });
|
|
47
|
+
}
|
|
48
|
+
static info(message) {
|
|
49
|
+
this.log('info', message);
|
|
50
|
+
}
|
|
51
|
+
static warn(message) {
|
|
52
|
+
this.log('warn', message);
|
|
53
|
+
}
|
|
54
|
+
static error(message) {
|
|
55
|
+
this.log('error', message);
|
|
56
|
+
}
|
|
57
|
+
static debug(message) {
|
|
58
|
+
this.log('debug', message);
|
|
59
|
+
}
|
|
60
|
+
static async flush() {
|
|
61
|
+
return new Promise((resolve) => {
|
|
62
|
+
this.transport.on('finish', resolve);
|
|
63
|
+
this.logger.end();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export type ClientMode = 'standard' | 'restricted';
|
|
3
|
+
export type LogLevel = 'error' | 'warn' | 'info' | 'debug';
|
|
4
|
+
export interface ToolplexServerConfig {
|
|
5
|
+
dev: boolean;
|
|
6
|
+
apiKey: string;
|
|
7
|
+
clientMode: ClientMode;
|
|
8
|
+
logLevel: LogLevel;
|
|
9
|
+
}
|
|
10
|
+
export declare const TransportTypeSchema: z.ZodEnum<["stdio", "sse"]>;
|
|
11
|
+
export type TransportType = z.infer<typeof TransportTypeSchema>;
|
|
12
|
+
export declare const RuntimeSchema: z.ZodEnum<["node", "python", "go", "docker"]>;
|
|
13
|
+
export type Runtime = z.infer<typeof RuntimeSchema>;
|
|
14
|
+
export declare const LLMContextSchema: z.ZodObject<{
|
|
15
|
+
model_family: z.ZodString;
|
|
16
|
+
model_name: z.ZodString;
|
|
17
|
+
model_version: z.ZodString;
|
|
18
|
+
chat_client: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, "strict", z.ZodTypeAny, {
|
|
20
|
+
model_family: string;
|
|
21
|
+
model_name: string;
|
|
22
|
+
model_version: string;
|
|
23
|
+
chat_client?: string | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
model_family: string;
|
|
26
|
+
model_name: string;
|
|
27
|
+
model_version: string;
|
|
28
|
+
chat_client?: string | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
export type LLMContext = z.infer<typeof LLMContextSchema>;
|
|
31
|
+
export declare const ServerConfigSchema: z.ZodObject<{
|
|
32
|
+
server_name: z.ZodOptional<z.ZodString>;
|
|
33
|
+
description: z.ZodOptional<z.ZodString>;
|
|
34
|
+
command: z.ZodOptional<z.ZodString>;
|
|
35
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
36
|
+
runtime: z.ZodOptional<z.ZodEnum<["node", "python", "go", "docker"]>>;
|
|
37
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
38
|
+
url: z.ZodOptional<z.ZodString>;
|
|
39
|
+
transport: z.ZodEnum<["stdio", "sse"]>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
transport: "stdio" | "sse";
|
|
42
|
+
server_name?: string | undefined;
|
|
43
|
+
description?: string | undefined;
|
|
44
|
+
command?: string | undefined;
|
|
45
|
+
args?: string[] | undefined;
|
|
46
|
+
runtime?: "node" | "python" | "go" | "docker" | undefined;
|
|
47
|
+
env?: Record<string, string> | undefined;
|
|
48
|
+
url?: string | undefined;
|
|
49
|
+
}, {
|
|
50
|
+
transport: "stdio" | "sse";
|
|
51
|
+
server_name?: string | undefined;
|
|
52
|
+
description?: string | undefined;
|
|
53
|
+
command?: string | undefined;
|
|
54
|
+
args?: string[] | undefined;
|
|
55
|
+
runtime?: "node" | "python" | "go" | "docker" | undefined;
|
|
56
|
+
env?: Record<string, string> | undefined;
|
|
57
|
+
url?: string | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
export type ServerConfig = z.infer<typeof ServerConfigSchema>;
|
|
60
|
+
export declare const InitializeToolplexParamsSchema: z.ZodObject<{
|
|
61
|
+
llm_context: z.ZodObject<{
|
|
62
|
+
model_family: z.ZodString;
|
|
63
|
+
model_name: z.ZodString;
|
|
64
|
+
model_version: z.ZodString;
|
|
65
|
+
chat_client: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, "strict", z.ZodTypeAny, {
|
|
67
|
+
model_family: string;
|
|
68
|
+
model_name: string;
|
|
69
|
+
model_version: string;
|
|
70
|
+
chat_client?: string | undefined;
|
|
71
|
+
}, {
|
|
72
|
+
model_family: string;
|
|
73
|
+
model_name: string;
|
|
74
|
+
model_version: string;
|
|
75
|
+
chat_client?: string | undefined;
|
|
76
|
+
}>;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
llm_context: {
|
|
79
|
+
model_family: string;
|
|
80
|
+
model_name: string;
|
|
81
|
+
model_version: string;
|
|
82
|
+
chat_client?: string | undefined;
|
|
83
|
+
};
|
|
84
|
+
}, {
|
|
85
|
+
llm_context: {
|
|
86
|
+
model_family: string;
|
|
87
|
+
model_name: string;
|
|
88
|
+
model_version: string;
|
|
89
|
+
chat_client?: string | undefined;
|
|
90
|
+
};
|
|
91
|
+
}>;
|
|
92
|
+
export type InitializeToolplexParams = z.infer<typeof InitializeToolplexParamsSchema>;
|
|
93
|
+
export declare const SearchParamsSchema: z.ZodObject<{
|
|
94
|
+
query: z.ZodString;
|
|
95
|
+
expanded_keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
96
|
+
filter: z.ZodOptional<z.ZodEnum<["all", "servers_only", "playbooks_only"]>>;
|
|
97
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
query: string;
|
|
100
|
+
filter?: "all" | "servers_only" | "playbooks_only" | undefined;
|
|
101
|
+
expanded_keywords?: string[] | undefined;
|
|
102
|
+
size?: number | undefined;
|
|
103
|
+
}, {
|
|
104
|
+
query: string;
|
|
105
|
+
filter?: "all" | "servers_only" | "playbooks_only" | undefined;
|
|
106
|
+
expanded_keywords?: string[] | undefined;
|
|
107
|
+
size?: number | undefined;
|
|
108
|
+
}>;
|
|
109
|
+
export type SearchParams = z.infer<typeof SearchParamsSchema>;
|
|
110
|
+
export declare const LookupEntityParamsSchema: z.ZodObject<{
|
|
111
|
+
entity_type: z.ZodEnum<["server", "playbook", "feedback"]>;
|
|
112
|
+
entity_id: z.ZodString;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
entity_type: "server" | "playbook" | "feedback";
|
|
115
|
+
entity_id: string;
|
|
116
|
+
}, {
|
|
117
|
+
entity_type: "server" | "playbook" | "feedback";
|
|
118
|
+
entity_id: string;
|
|
119
|
+
}>;
|
|
120
|
+
export type LookupEntityParams = z.infer<typeof LookupEntityParamsSchema>;
|
|
121
|
+
export declare const InstallParamsSchema: z.ZodObject<{
|
|
122
|
+
server_id: z.ZodString;
|
|
123
|
+
server_name: z.ZodString;
|
|
124
|
+
description: z.ZodString;
|
|
125
|
+
config: z.ZodObject<{
|
|
126
|
+
server_name: z.ZodOptional<z.ZodString>;
|
|
127
|
+
description: z.ZodOptional<z.ZodString>;
|
|
128
|
+
command: z.ZodOptional<z.ZodString>;
|
|
129
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
130
|
+
runtime: z.ZodOptional<z.ZodEnum<["node", "python", "go", "docker"]>>;
|
|
131
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
132
|
+
url: z.ZodOptional<z.ZodString>;
|
|
133
|
+
transport: z.ZodEnum<["stdio", "sse"]>;
|
|
134
|
+
}, "strip", z.ZodTypeAny, {
|
|
135
|
+
transport: "stdio" | "sse";
|
|
136
|
+
server_name?: string | undefined;
|
|
137
|
+
description?: string | undefined;
|
|
138
|
+
command?: string | undefined;
|
|
139
|
+
args?: string[] | undefined;
|
|
140
|
+
runtime?: "node" | "python" | "go" | "docker" | undefined;
|
|
141
|
+
env?: Record<string, string> | undefined;
|
|
142
|
+
url?: string | undefined;
|
|
143
|
+
}, {
|
|
144
|
+
transport: "stdio" | "sse";
|
|
145
|
+
server_name?: string | undefined;
|
|
146
|
+
description?: string | undefined;
|
|
147
|
+
command?: string | undefined;
|
|
148
|
+
args?: string[] | undefined;
|
|
149
|
+
runtime?: "node" | "python" | "go" | "docker" | undefined;
|
|
150
|
+
env?: Record<string, string> | undefined;
|
|
151
|
+
url?: string | undefined;
|
|
152
|
+
}>;
|
|
153
|
+
}, "strip", z.ZodTypeAny, {
|
|
154
|
+
server_name: string;
|
|
155
|
+
description: string;
|
|
156
|
+
server_id: string;
|
|
157
|
+
config: {
|
|
158
|
+
transport: "stdio" | "sse";
|
|
159
|
+
server_name?: string | undefined;
|
|
160
|
+
description?: string | undefined;
|
|
161
|
+
command?: string | undefined;
|
|
162
|
+
args?: string[] | undefined;
|
|
163
|
+
runtime?: "node" | "python" | "go" | "docker" | undefined;
|
|
164
|
+
env?: Record<string, string> | undefined;
|
|
165
|
+
url?: string | undefined;
|
|
166
|
+
};
|
|
167
|
+
}, {
|
|
168
|
+
server_name: string;
|
|
169
|
+
description: string;
|
|
170
|
+
server_id: string;
|
|
171
|
+
config: {
|
|
172
|
+
transport: "stdio" | "sse";
|
|
173
|
+
server_name?: string | undefined;
|
|
174
|
+
description?: string | undefined;
|
|
175
|
+
command?: string | undefined;
|
|
176
|
+
args?: string[] | undefined;
|
|
177
|
+
runtime?: "node" | "python" | "go" | "docker" | undefined;
|
|
178
|
+
env?: Record<string, string> | undefined;
|
|
179
|
+
url?: string | undefined;
|
|
180
|
+
};
|
|
181
|
+
}>;
|
|
182
|
+
export type InstallParams = z.infer<typeof InstallParamsSchema>;
|
|
183
|
+
export declare const ListToolsParamsSchema: z.ZodObject<{
|
|
184
|
+
server_id: z.ZodOptional<z.ZodString>;
|
|
185
|
+
}, "strip", z.ZodTypeAny, {
|
|
186
|
+
server_id?: string | undefined;
|
|
187
|
+
}, {
|
|
188
|
+
server_id?: string | undefined;
|
|
189
|
+
}>;
|
|
190
|
+
export type ListToolplexToolsParams = z.infer<typeof ListToolsParamsSchema>;
|
|
191
|
+
export declare const GetServerConfigParamsSchema: z.ZodObject<{
|
|
192
|
+
server_id: z.ZodOptional<z.ZodString>;
|
|
193
|
+
}, "strip", z.ZodTypeAny, {
|
|
194
|
+
server_id?: string | undefined;
|
|
195
|
+
}, {
|
|
196
|
+
server_id?: string | undefined;
|
|
197
|
+
}>;
|
|
198
|
+
export type GetServerConfigParams = z.infer<typeof GetServerConfigParamsSchema>;
|
|
199
|
+
export declare const CallToolParamsSchema: z.ZodObject<{
|
|
200
|
+
server_id: z.ZodString;
|
|
201
|
+
tool_name: z.ZodString;
|
|
202
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
203
|
+
}, "strip", z.ZodTypeAny, {
|
|
204
|
+
server_id: string;
|
|
205
|
+
tool_name: string;
|
|
206
|
+
arguments: Record<string, any>;
|
|
207
|
+
}, {
|
|
208
|
+
server_id: string;
|
|
209
|
+
tool_name: string;
|
|
210
|
+
arguments: Record<string, any>;
|
|
211
|
+
}>;
|
|
212
|
+
export type CallToolParams = z.infer<typeof CallToolParamsSchema>;
|
|
213
|
+
export declare const UninstallParamsSchema: z.ZodObject<{
|
|
214
|
+
server_id: z.ZodString;
|
|
215
|
+
}, "strip", z.ZodTypeAny, {
|
|
216
|
+
server_id: string;
|
|
217
|
+
}, {
|
|
218
|
+
server_id: string;
|
|
219
|
+
}>;
|
|
220
|
+
export type UninstallParams = z.infer<typeof UninstallParamsSchema>;
|
|
221
|
+
export declare const PlaybookActionSchema: z.ZodObject<{
|
|
222
|
+
do: z.ZodString;
|
|
223
|
+
call: z.ZodOptional<z.ZodString>;
|
|
224
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
225
|
+
type: z.ZodEnum<["string", "number", "boolean", "array", "object", "placeholder"]>;
|
|
226
|
+
example: z.ZodAny;
|
|
227
|
+
}, "strip", z.ZodTypeAny, {
|
|
228
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "placeholder";
|
|
229
|
+
example?: any;
|
|
230
|
+
}, {
|
|
231
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "placeholder";
|
|
232
|
+
example?: any;
|
|
233
|
+
}>>>;
|
|
234
|
+
}, "strip", z.ZodTypeAny, {
|
|
235
|
+
do: string;
|
|
236
|
+
args?: Record<string, {
|
|
237
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "placeholder";
|
|
238
|
+
example?: any;
|
|
239
|
+
}> | undefined;
|
|
240
|
+
call?: string | undefined;
|
|
241
|
+
}, {
|
|
242
|
+
do: string;
|
|
243
|
+
args?: Record<string, {
|
|
244
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "placeholder";
|
|
245
|
+
example?: any;
|
|
246
|
+
}> | undefined;
|
|
247
|
+
call?: string | undefined;
|
|
248
|
+
}>;
|
|
249
|
+
export type PlaybookAction = z.infer<typeof PlaybookActionSchema>;
|
|
250
|
+
export declare const SavePlaybookParamsSchema: z.ZodObject<{
|
|
251
|
+
description: z.ZodString;
|
|
252
|
+
actions: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
253
|
+
do: z.ZodString;
|
|
254
|
+
call: z.ZodOptional<z.ZodString>;
|
|
255
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
256
|
+
type: z.ZodEnum<["string", "number", "boolean", "array", "object", "placeholder"]>;
|
|
257
|
+
example: z.ZodAny;
|
|
258
|
+
}, "strip", z.ZodTypeAny, {
|
|
259
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "placeholder";
|
|
260
|
+
example?: any;
|
|
261
|
+
}, {
|
|
262
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "placeholder";
|
|
263
|
+
example?: any;
|
|
264
|
+
}>>>;
|
|
265
|
+
}, "strip", z.ZodTypeAny, {
|
|
266
|
+
do: string;
|
|
267
|
+
args?: Record<string, {
|
|
268
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "placeholder";
|
|
269
|
+
example?: any;
|
|
270
|
+
}> | undefined;
|
|
271
|
+
call?: string | undefined;
|
|
272
|
+
}, {
|
|
273
|
+
do: string;
|
|
274
|
+
args?: Record<string, {
|
|
275
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "placeholder";
|
|
276
|
+
example?: any;
|
|
277
|
+
}> | undefined;
|
|
278
|
+
call?: string | undefined;
|
|
279
|
+
}>, "many">, {
|
|
280
|
+
do: string;
|
|
281
|
+
args?: Record<string, {
|
|
282
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "placeholder";
|
|
283
|
+
example?: any;
|
|
284
|
+
}> | undefined;
|
|
285
|
+
call?: string | undefined;
|
|
286
|
+
}[], {
|
|
287
|
+
do: string;
|
|
288
|
+
args?: Record<string, {
|
|
289
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "placeholder";
|
|
290
|
+
example?: any;
|
|
291
|
+
}> | undefined;
|
|
292
|
+
call?: string | undefined;
|
|
293
|
+
}[]>;
|
|
294
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
295
|
+
keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
296
|
+
requirements: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
297
|
+
source_playbook_id: z.ZodOptional<z.ZodString>;
|
|
298
|
+
fork_reason: z.ZodOptional<z.ZodString>;
|
|
299
|
+
}, "strip", z.ZodTypeAny, {
|
|
300
|
+
description: string;
|
|
301
|
+
actions: {
|
|
302
|
+
do: string;
|
|
303
|
+
args?: Record<string, {
|
|
304
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "placeholder";
|
|
305
|
+
example?: any;
|
|
306
|
+
}> | undefined;
|
|
307
|
+
call?: string | undefined;
|
|
308
|
+
}[];
|
|
309
|
+
domain?: string | undefined;
|
|
310
|
+
keywords?: string[] | undefined;
|
|
311
|
+
requirements?: string[] | undefined;
|
|
312
|
+
source_playbook_id?: string | undefined;
|
|
313
|
+
fork_reason?: string | undefined;
|
|
314
|
+
}, {
|
|
315
|
+
description: string;
|
|
316
|
+
actions: {
|
|
317
|
+
do: string;
|
|
318
|
+
args?: Record<string, {
|
|
319
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "placeholder";
|
|
320
|
+
example?: any;
|
|
321
|
+
}> | undefined;
|
|
322
|
+
call?: string | undefined;
|
|
323
|
+
}[];
|
|
324
|
+
domain?: string | undefined;
|
|
325
|
+
keywords?: string[] | undefined;
|
|
326
|
+
requirements?: string[] | undefined;
|
|
327
|
+
source_playbook_id?: string | undefined;
|
|
328
|
+
fork_reason?: string | undefined;
|
|
329
|
+
}>;
|
|
330
|
+
export type SavePlaybookParams = z.infer<typeof SavePlaybookParamsSchema>;
|
|
331
|
+
export declare const LogPlaybookUsageParamsSchema: z.ZodObject<{
|
|
332
|
+
playbook_id: z.ZodString;
|
|
333
|
+
success: z.ZodBoolean;
|
|
334
|
+
error_message: z.ZodOptional<z.ZodString>;
|
|
335
|
+
}, "strip", z.ZodTypeAny, {
|
|
336
|
+
playbook_id: string;
|
|
337
|
+
success: boolean;
|
|
338
|
+
error_message?: string | undefined;
|
|
339
|
+
}, {
|
|
340
|
+
playbook_id: string;
|
|
341
|
+
success: boolean;
|
|
342
|
+
error_message?: string | undefined;
|
|
343
|
+
}>;
|
|
344
|
+
export type LogPlaybookUsageParams = z.infer<typeof LogPlaybookUsageParamsSchema>;
|
|
345
|
+
export declare const SubmitFeedbackParamsSchema: z.ZodObject<{
|
|
346
|
+
target_type: z.ZodEnum<["server", "playbook"]>;
|
|
347
|
+
target_id: z.ZodString;
|
|
348
|
+
vote: z.ZodEnum<["up", "down"]>;
|
|
349
|
+
message: z.ZodOptional<z.ZodString>;
|
|
350
|
+
security_assessment: z.ZodOptional<z.ZodObject<{
|
|
351
|
+
security_flags: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
352
|
+
custom_flag: z.ZodString;
|
|
353
|
+
}, "strip", z.ZodTypeAny, {
|
|
354
|
+
custom_flag: string;
|
|
355
|
+
}, {
|
|
356
|
+
custom_flag: string;
|
|
357
|
+
}>]>, "many">;
|
|
358
|
+
risk_assessment: z.ZodString;
|
|
359
|
+
context_note: z.ZodOptional<z.ZodString>;
|
|
360
|
+
}, "strip", z.ZodTypeAny, {
|
|
361
|
+
security_flags: (string | {
|
|
362
|
+
custom_flag: string;
|
|
363
|
+
})[];
|
|
364
|
+
risk_assessment: string;
|
|
365
|
+
context_note?: string | undefined;
|
|
366
|
+
}, {
|
|
367
|
+
security_flags: (string | {
|
|
368
|
+
custom_flag: string;
|
|
369
|
+
})[];
|
|
370
|
+
risk_assessment: string;
|
|
371
|
+
context_note?: string | undefined;
|
|
372
|
+
}>>;
|
|
373
|
+
}, "strip", z.ZodTypeAny, {
|
|
374
|
+
target_type: "server" | "playbook";
|
|
375
|
+
target_id: string;
|
|
376
|
+
vote: "up" | "down";
|
|
377
|
+
message?: string | undefined;
|
|
378
|
+
security_assessment?: {
|
|
379
|
+
security_flags: (string | {
|
|
380
|
+
custom_flag: string;
|
|
381
|
+
})[];
|
|
382
|
+
risk_assessment: string;
|
|
383
|
+
context_note?: string | undefined;
|
|
384
|
+
} | undefined;
|
|
385
|
+
}, {
|
|
386
|
+
target_type: "server" | "playbook";
|
|
387
|
+
target_id: string;
|
|
388
|
+
vote: "up" | "down";
|
|
389
|
+
message?: string | undefined;
|
|
390
|
+
security_assessment?: {
|
|
391
|
+
security_flags: (string | {
|
|
392
|
+
custom_flag: string;
|
|
393
|
+
})[];
|
|
394
|
+
risk_assessment: string;
|
|
395
|
+
context_note?: string | undefined;
|
|
396
|
+
} | undefined;
|
|
397
|
+
}>;
|
|
398
|
+
export type SubmitFeedbackParams = z.infer<typeof SubmitFeedbackParamsSchema>;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// src/types/types.ts
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
// --------------------
|
|
4
|
+
// Enums
|
|
5
|
+
// --------------------
|
|
6
|
+
export const TransportTypeSchema = z.enum(['stdio', 'sse']);
|
|
7
|
+
export const RuntimeSchema = z.enum(['node', 'python', 'go', 'docker']);
|
|
8
|
+
// --------------------
|
|
9
|
+
// LLMContext
|
|
10
|
+
// --------------------
|
|
11
|
+
export const LLMContextSchema = z
|
|
12
|
+
.object({
|
|
13
|
+
model_family: z.string(),
|
|
14
|
+
model_name: z.string().min(1),
|
|
15
|
+
model_version: z.string(),
|
|
16
|
+
chat_client: z.string().optional(),
|
|
17
|
+
})
|
|
18
|
+
.strict();
|
|
19
|
+
// --------------------
|
|
20
|
+
// ServerConfig
|
|
21
|
+
// --------------------
|
|
22
|
+
export const ServerConfigSchema = z.object({
|
|
23
|
+
server_name: z.string().optional(),
|
|
24
|
+
description: z.string().optional(),
|
|
25
|
+
command: z.string().optional(),
|
|
26
|
+
args: z.array(z.string()).optional(),
|
|
27
|
+
runtime: RuntimeSchema.optional(),
|
|
28
|
+
env: z.record(z.string()).optional(),
|
|
29
|
+
url: z.string().optional(),
|
|
30
|
+
transport: TransportTypeSchema,
|
|
31
|
+
});
|
|
32
|
+
// --------------------
|
|
33
|
+
// InitializeToolplexParams
|
|
34
|
+
// --------------------
|
|
35
|
+
export const InitializeToolplexParamsSchema = z.object({
|
|
36
|
+
llm_context: LLMContextSchema,
|
|
37
|
+
});
|
|
38
|
+
// --------------------
|
|
39
|
+
// SearchParams
|
|
40
|
+
// --------------------
|
|
41
|
+
export const SearchParamsSchema = z.object({
|
|
42
|
+
query: z.string(),
|
|
43
|
+
expanded_keywords: z.array(z.string()).optional(),
|
|
44
|
+
filter: z.enum(['all', 'servers_only', 'playbooks_only']).optional(),
|
|
45
|
+
size: z.number().int().min(1).max(25).optional(),
|
|
46
|
+
});
|
|
47
|
+
// --------------------
|
|
48
|
+
// LookupEntityParams
|
|
49
|
+
// --------------------
|
|
50
|
+
export const LookupEntityParamsSchema = z.object({
|
|
51
|
+
entity_type: z.enum(['server', 'playbook', 'feedback']),
|
|
52
|
+
entity_id: z.string(),
|
|
53
|
+
});
|
|
54
|
+
// --------------------
|
|
55
|
+
// InstallParams
|
|
56
|
+
// --------------------
|
|
57
|
+
export const InstallParamsSchema = z.object({
|
|
58
|
+
server_id: z.string(),
|
|
59
|
+
server_name: z.string(),
|
|
60
|
+
description: z.string(),
|
|
61
|
+
config: ServerConfigSchema,
|
|
62
|
+
});
|
|
63
|
+
// --------------------
|
|
64
|
+
// ListToolsParams
|
|
65
|
+
// --------------------
|
|
66
|
+
export const ListToolsParamsSchema = z.object({
|
|
67
|
+
server_id: z.string().optional(),
|
|
68
|
+
});
|
|
69
|
+
// --------------------
|
|
70
|
+
// GetServerConfigParams
|
|
71
|
+
// --------------------
|
|
72
|
+
export const GetServerConfigParamsSchema = z.object({
|
|
73
|
+
server_id: z.string().optional(),
|
|
74
|
+
});
|
|
75
|
+
// --------------------
|
|
76
|
+
// CallToolParams
|
|
77
|
+
// --------------------
|
|
78
|
+
export const CallToolParamsSchema = z.object({
|
|
79
|
+
server_id: z.string(),
|
|
80
|
+
tool_name: z.string(),
|
|
81
|
+
arguments: z.record(z.any()),
|
|
82
|
+
});
|
|
83
|
+
// --------------------
|
|
84
|
+
// UninstallParams
|
|
85
|
+
// --------------------
|
|
86
|
+
export const UninstallParamsSchema = z.object({
|
|
87
|
+
server_id: z.string(),
|
|
88
|
+
});
|
|
89
|
+
// --------------------
|
|
90
|
+
// PlaybookAction (shared type for actions)
|
|
91
|
+
// --------------------
|
|
92
|
+
export const PlaybookActionSchema = z.object({
|
|
93
|
+
do: z.string(),
|
|
94
|
+
call: z.string().optional(),
|
|
95
|
+
args: z
|
|
96
|
+
.record(z.object({
|
|
97
|
+
type: z.enum(['string', 'number', 'boolean', 'array', 'object', 'placeholder']),
|
|
98
|
+
example: z.any(),
|
|
99
|
+
}))
|
|
100
|
+
.optional(),
|
|
101
|
+
});
|
|
102
|
+
// --------------------
|
|
103
|
+
// SavePlaybookParams
|
|
104
|
+
// --------------------
|
|
105
|
+
export const SavePlaybookParamsSchema = z.object({
|
|
106
|
+
description: z.string(),
|
|
107
|
+
// Requires at least one action to have a "call" property
|
|
108
|
+
actions: z
|
|
109
|
+
.array(PlaybookActionSchema)
|
|
110
|
+
.refine((actions) => actions.some((action) => typeof action.call === 'string' && action.call.length > 0), {
|
|
111
|
+
message: 'At least one action must include a "call" property',
|
|
112
|
+
path: ['actions'],
|
|
113
|
+
}),
|
|
114
|
+
domain: z.string().optional(),
|
|
115
|
+
keywords: z.array(z.string()).optional(),
|
|
116
|
+
requirements: z.array(z.string()).optional(),
|
|
117
|
+
source_playbook_id: z.string().optional(),
|
|
118
|
+
fork_reason: z.string().optional(),
|
|
119
|
+
});
|
|
120
|
+
// --------------------
|
|
121
|
+
// LogPlaybookUsageParams
|
|
122
|
+
// --------------------
|
|
123
|
+
export const LogPlaybookUsageParamsSchema = z.object({
|
|
124
|
+
playbook_id: z.string(),
|
|
125
|
+
success: z.boolean(),
|
|
126
|
+
error_message: z.string().optional(),
|
|
127
|
+
});
|
|
128
|
+
// --------------------
|
|
129
|
+
// SubmitFeedbackParams
|
|
130
|
+
// --------------------
|
|
131
|
+
export const SubmitFeedbackParamsSchema = z.object({
|
|
132
|
+
target_type: z.enum(['server', 'playbook']),
|
|
133
|
+
target_id: z.string(),
|
|
134
|
+
vote: z.enum(['up', 'down']),
|
|
135
|
+
message: z.string().optional(),
|
|
136
|
+
security_assessment: z
|
|
137
|
+
.object({
|
|
138
|
+
security_flags: z.array(z.union([
|
|
139
|
+
z.string(),
|
|
140
|
+
z.object({
|
|
141
|
+
custom_flag: z.string(),
|
|
142
|
+
}),
|
|
143
|
+
])),
|
|
144
|
+
risk_assessment: z.string(),
|
|
145
|
+
context_note: z.string().optional(),
|
|
146
|
+
})
|
|
147
|
+
.optional(),
|
|
148
|
+
});
|