@juspay/neurolink 5.3.0 → 6.0.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/CHANGELOG.md +76 -2
- package/dist/chat/client-utils.d.ts +3 -0
- package/dist/chat/client-utils.js +22 -5
- package/dist/chat/index.d.ts +4 -7
- package/dist/chat/index.js +0 -8
- package/dist/chat/session-storage.d.ts +2 -2
- package/dist/chat/session.d.ts +4 -3
- package/dist/chat/session.js +1 -1
- package/dist/chat/sse-handler.js +13 -21
- package/dist/chat/types.d.ts +3 -2
- package/dist/chat/websocket-chat-handler.d.ts +4 -3
- package/dist/chat/websocket-chat-handler.js +12 -12
- package/dist/cli/commands/config.d.ts +2 -2
- package/dist/cli/commands/mcp.d.ts +3 -2
- package/dist/cli/commands/mcp.js +39 -29
- package/dist/cli/commands/ollama.js +8 -4
- package/dist/cli/factories/command-factory.d.ts +2 -1
- package/dist/cli/index.js +22 -19
- package/dist/core/analytics.d.ts +3 -2
- package/dist/core/analytics.js +16 -7
- package/dist/core/base-provider.d.ts +35 -7
- package/dist/core/base-provider.js +36 -13
- package/dist/core/defaults.d.ts +2 -1
- package/dist/core/evaluation.d.ts +4 -4
- package/dist/core/evaluation.js +17 -7
- package/dist/core/factory.d.ts +3 -2
- package/dist/core/service-registry.d.ts +4 -4
- package/dist/core/types.d.ts +11 -4
- package/dist/factories/compatibility-factory.d.ts +16 -1
- package/dist/factories/compatibility-factory.js +3 -1
- package/dist/factories/provider-factory.d.ts +5 -4
- package/dist/factories/provider-factory.js +15 -24
- package/dist/factories/provider-generate-factory.js +26 -20
- package/dist/lib/chat/client-utils.d.ts +3 -0
- package/dist/lib/chat/client-utils.js +22 -5
- package/dist/lib/chat/index.d.ts +4 -7
- package/dist/lib/chat/index.js +0 -8
- package/dist/lib/chat/session-storage.d.ts +2 -2
- package/dist/lib/chat/session.d.ts +4 -3
- package/dist/lib/chat/session.js +1 -1
- package/dist/lib/chat/sse-handler.js +13 -21
- package/dist/lib/chat/types.d.ts +3 -2
- package/dist/lib/chat/websocket-chat-handler.d.ts +4 -3
- package/dist/lib/chat/websocket-chat-handler.js +12 -12
- package/dist/lib/core/analytics.d.ts +3 -2
- package/dist/lib/core/analytics.js +16 -7
- package/dist/lib/core/base-provider.d.ts +35 -7
- package/dist/lib/core/base-provider.js +36 -13
- package/dist/lib/core/defaults.d.ts +2 -1
- package/dist/lib/core/evaluation.d.ts +4 -4
- package/dist/lib/core/evaluation.js +17 -7
- package/dist/lib/core/factory.d.ts +3 -2
- package/dist/lib/core/service-registry.d.ts +4 -4
- package/dist/lib/core/types.d.ts +11 -4
- package/dist/lib/factories/compatibility-factory.d.ts +16 -1
- package/dist/lib/factories/compatibility-factory.js +3 -1
- package/dist/lib/factories/provider-factory.d.ts +5 -4
- package/dist/lib/factories/provider-factory.js +15 -24
- package/dist/lib/factories/provider-generate-factory.js +26 -20
- package/dist/lib/mcp/adapters/plugin-bridge.d.ts +5 -4
- package/dist/lib/mcp/adapters/plugin-bridge.js +13 -6
- package/dist/lib/mcp/client.d.ts +2 -1
- package/dist/lib/mcp/client.js +12 -10
- package/dist/lib/mcp/context-manager.d.ts +1 -1
- package/dist/lib/mcp/contracts/mcp-contract.d.ts +15 -8
- package/dist/lib/mcp/core/plugin-manager.d.ts +3 -2
- package/dist/lib/mcp/core/plugin-manager.js +1 -1
- package/dist/lib/mcp/demo/plugin-demo.js +3 -1
- package/dist/lib/mcp/dynamic-chain-executor.d.ts +64 -40
- package/dist/lib/mcp/dynamic-chain-executor.js +3 -3
- package/dist/lib/mcp/dynamic-orchestrator.d.ts +14 -8
- package/dist/lib/mcp/ecosystem.d.ts +4 -4
- package/dist/lib/mcp/error-manager.d.ts +2 -2
- package/dist/lib/mcp/error-recovery.d.ts +4 -3
- package/dist/lib/mcp/external-client.d.ts +1 -1
- package/dist/lib/mcp/external-client.js +14 -10
- package/dist/lib/mcp/external-manager.d.ts +3 -3
- package/dist/lib/mcp/external-manager.js +9 -3
- package/dist/lib/mcp/factory.d.ts +7 -7
- package/dist/lib/mcp/function-calling.d.ts +3 -2
- package/dist/lib/mcp/health-monitor.d.ts +2 -1
- package/dist/lib/mcp/health-monitor.js +16 -7
- package/dist/lib/mcp/index.d.ts +5 -5
- package/dist/lib/mcp/initialize-tools.d.ts +2 -1
- package/dist/lib/mcp/initialize-tools.js +10 -2
- package/dist/lib/mcp/manager.d.ts +2 -1
- package/dist/lib/mcp/neurolink-mcp-client.js +1 -1
- package/dist/lib/mcp/orchestrator.d.ts +13 -12
- package/dist/lib/mcp/orchestrator.js +10 -8
- package/dist/lib/mcp/plugin-manager.js +4 -2
- package/dist/lib/mcp/plugins/core/filesystem-mcp.d.ts +3 -2
- package/dist/lib/mcp/plugins/core/filesystem-mcp.js +5 -2
- package/dist/lib/mcp/plugins/filesystem-mcp.d.ts +2 -1
- package/dist/lib/mcp/registry.d.ts +2 -1
- package/dist/lib/mcp/registry.js +2 -1
- package/dist/lib/mcp/security-manager.d.ts +4 -2
- package/dist/lib/mcp/servers/agent/direct-tools-server.js +18 -6
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -16
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +21 -17
- package/dist/lib/mcp/servers/ai-providers/ai-core-server.d.ts +2 -2
- package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +15 -133
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +1 -97
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +18 -18
- package/dist/lib/mcp/session-manager.d.ts +4 -3
- package/dist/lib/mcp/session-persistence.js +5 -2
- package/dist/lib/mcp/tool-integration.d.ts +3 -2
- package/dist/lib/mcp/tool-integration.js +3 -1
- package/dist/lib/mcp/tool-registry.d.ts +18 -1
- package/dist/lib/mcp/tool-registry.js +11 -8
- package/dist/lib/mcp/transport-manager.d.ts +2 -1
- package/dist/lib/mcp/transport-manager.js +5 -1
- package/dist/lib/mcp/unified-mcp.d.ts +5 -5
- package/dist/lib/mcp/unified-registry.d.ts +18 -2
- package/dist/lib/mcp/unified-registry.js +52 -3
- package/dist/lib/neurolink.d.ts +2 -2
- package/dist/lib/neurolink.js +40 -15
- package/dist/lib/providers/amazon-bedrock.d.ts +1 -1
- package/dist/lib/providers/amazon-bedrock.js +8 -7
- package/dist/lib/providers/analytics-helper.d.ts +8 -23
- package/dist/lib/providers/analytics-helper.js +95 -33
- package/dist/lib/providers/anthropic-baseprovider.d.ts +3 -3
- package/dist/lib/providers/anthropic-baseprovider.js +6 -5
- package/dist/lib/providers/anthropic.d.ts +2 -2
- package/dist/lib/providers/anthropic.js +11 -4
- package/dist/lib/providers/azure-openai.d.ts +5 -4
- package/dist/lib/providers/azure-openai.js +10 -4
- package/dist/lib/providers/function-calling-provider.d.ts +2 -2
- package/dist/lib/providers/function-calling-provider.js +1 -1
- package/dist/lib/providers/google-ai-studio.d.ts +2 -2
- package/dist/lib/providers/google-ai-studio.js +9 -3
- package/dist/lib/providers/google-vertex.d.ts +2 -2
- package/dist/lib/providers/google-vertex.js +18 -12
- package/dist/lib/providers/huggingFace.d.ts +1 -1
- package/dist/lib/providers/huggingFace.js +8 -4
- package/dist/lib/providers/mcp-provider.d.ts +3 -3
- package/dist/lib/providers/mistral.d.ts +34 -27
- package/dist/lib/providers/mistral.js +115 -107
- package/dist/lib/providers/ollama.d.ts +2 -1
- package/dist/lib/providers/ollama.js +43 -3
- package/dist/lib/providers/openAI.d.ts +1 -1
- package/dist/lib/providers/openAI.js +8 -4
- package/dist/lib/proxy/proxy-fetch.js +3 -2
- package/dist/lib/sdk/tool-extension.d.ts +12 -12
- package/dist/lib/sdk/tool-extension.js +2 -1
- package/dist/lib/sdk/tool-registration.d.ts +16 -12
- package/dist/lib/sdk/tool-registration.js +3 -2
- package/dist/lib/services/types.d.ts +5 -4
- package/dist/lib/services/websocket/websocket-server.d.ts +1 -1
- package/dist/lib/services/websocket/websocket-server.js +1 -1
- package/dist/lib/telemetry/telemetry-service.js +1 -1
- package/dist/lib/types/cli.d.ts +247 -0
- package/dist/lib/types/cli.js +22 -0
- package/dist/lib/types/common.d.ts +76 -0
- package/dist/lib/types/common.js +52 -0
- package/dist/lib/types/generate-types.d.ts +6 -6
- package/dist/lib/types/index.d.ts +12 -0
- package/dist/lib/types/index.js +12 -0
- package/dist/lib/types/mcp-types.d.ts +7 -7
- package/dist/lib/types/providers.d.ts +158 -0
- package/dist/lib/types/providers.js +23 -0
- package/dist/lib/types/stream-types.d.ts +4 -3
- package/dist/lib/types/tools.d.ts +154 -0
- package/dist/lib/types/tools.js +24 -0
- package/dist/lib/utils/logger.d.ts +5 -5
- package/dist/lib/utils/provider-validation.d.ts +2 -1
- package/dist/mcp/adapters/plugin-bridge.d.ts +5 -4
- package/dist/mcp/adapters/plugin-bridge.js +13 -6
- package/dist/mcp/client.d.ts +2 -1
- package/dist/mcp/client.js +12 -10
- package/dist/mcp/context-manager.d.ts +1 -1
- package/dist/mcp/contracts/mcp-contract.d.ts +15 -8
- package/dist/mcp/core/plugin-manager.d.ts +3 -2
- package/dist/mcp/core/plugin-manager.js +1 -1
- package/dist/mcp/demo/plugin-demo.js +3 -1
- package/dist/mcp/dynamic-chain-executor.d.ts +64 -40
- package/dist/mcp/dynamic-chain-executor.js +3 -3
- package/dist/mcp/dynamic-orchestrator.d.ts +14 -8
- package/dist/mcp/dynamic-orchestrator.js +1 -1
- package/dist/mcp/ecosystem.d.ts +4 -4
- package/dist/mcp/error-manager.d.ts +2 -2
- package/dist/mcp/error-recovery.d.ts +4 -3
- package/dist/mcp/external-client.d.ts +1 -1
- package/dist/mcp/external-client.js +14 -10
- package/dist/mcp/external-manager.d.ts +3 -3
- package/dist/mcp/external-manager.js +9 -3
- package/dist/mcp/factory.d.ts +7 -7
- package/dist/mcp/function-calling.d.ts +3 -2
- package/dist/mcp/health-monitor.d.ts +2 -1
- package/dist/mcp/health-monitor.js +16 -7
- package/dist/mcp/index.d.ts +5 -5
- package/dist/mcp/initialize-tools.d.ts +2 -1
- package/dist/mcp/initialize-tools.js +10 -2
- package/dist/mcp/manager.d.ts +2 -1
- package/dist/mcp/neurolink-mcp-client.js +1 -1
- package/dist/mcp/orchestrator.d.ts +13 -12
- package/dist/mcp/orchestrator.js +10 -8
- package/dist/mcp/plugin-manager.js +4 -2
- package/dist/mcp/plugins/core/filesystem-mcp.d.ts +3 -2
- package/dist/mcp/plugins/core/filesystem-mcp.js +5 -2
- package/dist/mcp/plugins/filesystem-mcp.d.ts +2 -1
- package/dist/mcp/registry.d.ts +2 -1
- package/dist/mcp/registry.js +2 -1
- package/dist/mcp/security-manager.d.ts +4 -2
- package/dist/mcp/servers/agent/direct-tools-server.js +19 -6
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -16
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +21 -17
- package/dist/mcp/servers/ai-providers/ai-core-server.d.ts +2 -2
- package/dist/mcp/servers/ai-providers/ai-core-server.js +15 -132
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +1 -97
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +18 -18
- package/dist/mcp/session-manager.d.ts +4 -3
- package/dist/mcp/session-persistence.js +5 -2
- package/dist/mcp/tool-integration.d.ts +3 -2
- package/dist/mcp/tool-integration.js +3 -1
- package/dist/mcp/tool-registry.d.ts +18 -1
- package/dist/mcp/tool-registry.js +11 -8
- package/dist/mcp/transport-manager.d.ts +2 -1
- package/dist/mcp/transport-manager.js +5 -1
- package/dist/mcp/unified-mcp.d.ts +5 -5
- package/dist/mcp/unified-registry.d.ts +18 -2
- package/dist/mcp/unified-registry.js +52 -3
- package/dist/neurolink.d.ts +2 -2
- package/dist/neurolink.js +40 -15
- package/dist/providers/amazon-bedrock.d.ts +1 -1
- package/dist/providers/amazon-bedrock.js +8 -7
- package/dist/providers/analytics-helper.d.ts +8 -23
- package/dist/providers/analytics-helper.js +95 -33
- package/dist/providers/anthropic-baseprovider.d.ts +3 -3
- package/dist/providers/anthropic-baseprovider.js +6 -5
- package/dist/providers/anthropic.d.ts +2 -2
- package/dist/providers/anthropic.js +11 -4
- package/dist/providers/azure-openai.d.ts +5 -4
- package/dist/providers/azure-openai.js +10 -4
- package/dist/providers/function-calling-provider.d.ts +2 -2
- package/dist/providers/function-calling-provider.js +1 -1
- package/dist/providers/google-ai-studio.d.ts +2 -2
- package/dist/providers/google-ai-studio.js +9 -3
- package/dist/providers/google-vertex.d.ts +2 -2
- package/dist/providers/google-vertex.js +18 -12
- package/dist/providers/huggingFace.d.ts +1 -1
- package/dist/providers/huggingFace.js +8 -4
- package/dist/providers/mcp-provider.d.ts +3 -3
- package/dist/providers/mistral.d.ts +34 -27
- package/dist/providers/mistral.js +116 -108
- package/dist/providers/ollama.d.ts +2 -1
- package/dist/providers/ollama.js +43 -3
- package/dist/providers/openAI.d.ts +1 -1
- package/dist/providers/openAI.js +8 -4
- package/dist/proxy/proxy-fetch.js +3 -2
- package/dist/sdk/tool-extension.d.ts +12 -12
- package/dist/sdk/tool-extension.js +2 -1
- package/dist/sdk/tool-registration.d.ts +16 -12
- package/dist/sdk/tool-registration.js +3 -2
- package/dist/services/types.d.ts +5 -4
- package/dist/services/websocket/websocket-server.d.ts +1 -1
- package/dist/services/websocket/websocket-server.js +2 -1
- package/dist/telemetry/telemetry-service.js +1 -1
- package/dist/types/cli.d.ts +247 -0
- package/dist/types/cli.js +22 -0
- package/dist/types/common.d.ts +76 -0
- package/dist/types/common.js +52 -0
- package/dist/types/generate-types.d.ts +6 -6
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js +12 -0
- package/dist/types/mcp-types.d.ts +7 -7
- package/dist/types/providers.d.ts +158 -0
- package/dist/types/providers.js +23 -0
- package/dist/types/stream-types.d.ts +4 -3
- package/dist/types/tools.d.ts +154 -0
- package/dist/types/tools.js +25 -0
- package/dist/utils/logger.d.ts +5 -5
- package/dist/utils/provider-validation.d.ts +2 -1
- package/package.json +1 -1
|
@@ -54,7 +54,8 @@ class OllamaLanguageModel {
|
|
|
54
54
|
.join("\n");
|
|
55
55
|
}
|
|
56
56
|
async doGenerate(options) {
|
|
57
|
-
const messages = options
|
|
57
|
+
const messages = options
|
|
58
|
+
.messages || [];
|
|
58
59
|
const prompt = this.convertMessagesToPrompt(messages);
|
|
59
60
|
const response = await fetch(`${this.baseUrl}/api/generate`, {
|
|
60
61
|
method: "POST",
|
|
@@ -80,11 +81,25 @@ class OllamaLanguageModel {
|
|
|
80
81
|
usage: {
|
|
81
82
|
promptTokens: this.estimateTokens(prompt),
|
|
82
83
|
completionTokens: this.estimateTokens(data.response),
|
|
84
|
+
totalTokens: this.estimateTokens(prompt) + this.estimateTokens(data.response),
|
|
85
|
+
},
|
|
86
|
+
finishReason: "stop",
|
|
87
|
+
rawCall: {
|
|
88
|
+
rawPrompt: prompt,
|
|
89
|
+
rawSettings: {
|
|
90
|
+
model: this.modelId,
|
|
91
|
+
temperature: options.temperature,
|
|
92
|
+
num_predict: options.maxTokens,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
rawResponse: {
|
|
96
|
+
headers: {},
|
|
83
97
|
},
|
|
84
98
|
};
|
|
85
99
|
}
|
|
86
100
|
async doStream(options) {
|
|
87
|
-
const messages = options
|
|
101
|
+
const messages = options
|
|
102
|
+
.messages || [];
|
|
88
103
|
const prompt = this.convertMessagesToPrompt(messages);
|
|
89
104
|
const response = await fetch(`${this.baseUrl}/api/generate`, {
|
|
90
105
|
method: "POST",
|
|
@@ -104,8 +119,32 @@ class OllamaLanguageModel {
|
|
|
104
119
|
if (!response.ok) {
|
|
105
120
|
throw new Error(`Ollama API error: ${response.status} ${response.statusText}`);
|
|
106
121
|
}
|
|
122
|
+
const self = this;
|
|
107
123
|
return {
|
|
108
|
-
stream:
|
|
124
|
+
stream: new ReadableStream({
|
|
125
|
+
async start(controller) {
|
|
126
|
+
try {
|
|
127
|
+
for await (const chunk of self.parseStreamResponse(response)) {
|
|
128
|
+
controller.enqueue(chunk);
|
|
129
|
+
}
|
|
130
|
+
controller.close();
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
controller.error(error);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
}),
|
|
137
|
+
rawCall: {
|
|
138
|
+
rawPrompt: prompt,
|
|
139
|
+
rawSettings: {
|
|
140
|
+
model: this.modelId,
|
|
141
|
+
temperature: options.temperature,
|
|
142
|
+
num_predict: options.maxTokens,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
rawResponse: {
|
|
146
|
+
headers: {},
|
|
147
|
+
},
|
|
109
148
|
};
|
|
110
149
|
}
|
|
111
150
|
async *parseStreamResponse(response) {
|
|
@@ -194,6 +233,7 @@ export class OllamaProvider extends BaseProvider {
|
|
|
194
233
|
}
|
|
195
234
|
/**
|
|
196
235
|
* Returns the Vercel AI SDK model instance for Ollama
|
|
236
|
+
* The OllamaLanguageModel implements LanguageModelV1 interface properly
|
|
197
237
|
*/
|
|
198
238
|
getAISDKModel() {
|
|
199
239
|
return this.ollamaModel;
|
|
@@ -16,7 +16,7 @@ export declare class OpenAIProvider extends BaseProvider {
|
|
|
16
16
|
* Returns the Vercel AI SDK model instance for OpenAI
|
|
17
17
|
*/
|
|
18
18
|
protected getAISDKModel(): LanguageModelV1;
|
|
19
|
-
protected handleProviderError(error:
|
|
19
|
+
protected handleProviderError(error: unknown): Error;
|
|
20
20
|
/**
|
|
21
21
|
* executeGenerate method removed - generation is now handled by BaseProvider.
|
|
22
22
|
* For details on the changes and migration steps, refer to the BaseProvider documentation
|
|
@@ -52,14 +52,18 @@ export class OpenAIProvider extends BaseProvider {
|
|
|
52
52
|
if (error instanceof TimeoutError) {
|
|
53
53
|
return new Error(`OpenAI request timed out: ${error.message}`);
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
const errorObj = error;
|
|
56
|
+
const message = errorObj?.message && typeof errorObj.message === "string"
|
|
57
|
+
? errorObj.message
|
|
58
|
+
: "Unknown error";
|
|
59
|
+
if (message.includes("API_KEY_INVALID") ||
|
|
60
|
+
message.includes("Invalid API key")) {
|
|
57
61
|
return new Error("Invalid OpenAI API key. Please check your OPENAI_API_KEY environment variable.");
|
|
58
62
|
}
|
|
59
|
-
if (
|
|
63
|
+
if (message.includes("rate limit")) {
|
|
60
64
|
return new Error("OpenAI rate limit exceeded. Please try again later.");
|
|
61
65
|
}
|
|
62
|
-
return new Error(`OpenAI error: ${
|
|
66
|
+
return new Error(`OpenAI error: ${message}`);
|
|
63
67
|
}
|
|
64
68
|
/**
|
|
65
69
|
* executeGenerate method removed - generation is now handled by BaseProvider.
|
|
@@ -40,11 +40,12 @@ export function createProxyFetch() {
|
|
|
40
40
|
dispatcher: dispatcher,
|
|
41
41
|
});
|
|
42
42
|
logger.debug(`[Proxy Fetch] ✅ Request proxied successfully to ${url.hostname}`);
|
|
43
|
-
return response; //
|
|
43
|
+
return response; // undici.fetch returns compatible Response type
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
catch (error) {
|
|
47
|
-
|
|
47
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
48
|
+
logger.warn(`[Proxy Fetch] Proxy failed (${errorMessage}), falling back to direct connection`);
|
|
48
49
|
}
|
|
49
50
|
// Fallback to standard fetch
|
|
50
51
|
return fetch(input, init);
|
|
@@ -16,11 +16,11 @@ export interface CustomTool {
|
|
|
16
16
|
/**
|
|
17
17
|
* Parameters schema using Zod or JSON Schema
|
|
18
18
|
*/
|
|
19
|
-
parameters?: z.ZodSchema | Record<string,
|
|
19
|
+
parameters?: z.ZodSchema | Record<string, unknown>;
|
|
20
20
|
/**
|
|
21
21
|
* Tool execution function
|
|
22
22
|
*/
|
|
23
|
-
execute: (args:
|
|
23
|
+
execute: (args: unknown, context?: ToolContext) => Promise<unknown> | unknown;
|
|
24
24
|
/**
|
|
25
25
|
* Optional metadata
|
|
26
26
|
*/
|
|
@@ -46,7 +46,7 @@ export interface ToolContext {
|
|
|
46
46
|
/**
|
|
47
47
|
* Call another tool
|
|
48
48
|
*/
|
|
49
|
-
callTool: (name: string, args:
|
|
49
|
+
callTool: (name: string, args: unknown) => Promise<unknown>;
|
|
50
50
|
/**
|
|
51
51
|
* Current session information
|
|
52
52
|
*/
|
|
@@ -64,7 +64,7 @@ export interface ToolContext {
|
|
|
64
64
|
/**
|
|
65
65
|
* Tool middleware function
|
|
66
66
|
*/
|
|
67
|
-
export type ToolMiddleware = (toolName: string, args:
|
|
67
|
+
export type ToolMiddleware = (toolName: string, args: unknown, next: () => Promise<unknown>, context: ToolContext) => Promise<unknown>;
|
|
68
68
|
/**
|
|
69
69
|
* Tool permission configuration
|
|
70
70
|
*/
|
|
@@ -72,7 +72,7 @@ export interface ToolPermissions {
|
|
|
72
72
|
allowlist?: string[];
|
|
73
73
|
denylist?: string[];
|
|
74
74
|
requireApproval?: string[];
|
|
75
|
-
customValidator?: (toolName: string, args:
|
|
75
|
+
customValidator?: (toolName: string, args: unknown) => boolean | Promise<boolean>;
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Converts a custom tool to Vercel AI SDK format
|
|
@@ -129,7 +129,7 @@ export declare class ToolRegistry {
|
|
|
129
129
|
/**
|
|
130
130
|
* Execute a tool with middleware
|
|
131
131
|
*/
|
|
132
|
-
execute(name: string, args:
|
|
132
|
+
execute(name: string, args: unknown, context: ToolContext): Promise<unknown>;
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
135
|
* Create a simple tool helper
|
|
@@ -139,7 +139,7 @@ export declare function createTool(config: CustomTool): CustomTool;
|
|
|
139
139
|
* Create an async tool helper
|
|
140
140
|
*/
|
|
141
141
|
export declare function createAsyncTool(config: Omit<CustomTool, "execute"> & {
|
|
142
|
-
execute: (args:
|
|
142
|
+
execute: (args: unknown, context?: ToolContext) => Promise<unknown>;
|
|
143
143
|
}): CustomTool;
|
|
144
144
|
/**
|
|
145
145
|
* Create a batch tool that processes multiple items
|
|
@@ -163,16 +163,16 @@ export declare const TestUtils: {
|
|
|
163
163
|
* Test a tool with mock data
|
|
164
164
|
*/
|
|
165
165
|
testTool(tool: CustomTool, testCases: Array<{
|
|
166
|
-
input:
|
|
167
|
-
expected?:
|
|
166
|
+
input: unknown;
|
|
167
|
+
expected?: unknown;
|
|
168
168
|
}>): Promise<({
|
|
169
|
-
input:
|
|
170
|
-
output:
|
|
169
|
+
input: unknown;
|
|
170
|
+
output: unknown;
|
|
171
171
|
success: boolean;
|
|
172
172
|
matches: boolean | undefined;
|
|
173
173
|
error?: undefined;
|
|
174
174
|
} | {
|
|
175
|
-
input:
|
|
175
|
+
input: unknown;
|
|
176
176
|
error: string;
|
|
177
177
|
success: boolean;
|
|
178
178
|
output?: undefined;
|
|
@@ -217,7 +217,8 @@ export function createAsyncTool(config) {
|
|
|
217
217
|
export function createBatchTool(config) {
|
|
218
218
|
return {
|
|
219
219
|
...config,
|
|
220
|
-
execute: async (
|
|
220
|
+
execute: async (args, context) => {
|
|
221
|
+
const { items } = args;
|
|
221
222
|
const batchSize = config.batchSize || 10;
|
|
222
223
|
const results = [];
|
|
223
224
|
for (let i = 0; i < items.length; i += batchSize) {
|
|
@@ -6,18 +6,17 @@ import { z } from "zod";
|
|
|
6
6
|
import type { Tool } from "ai";
|
|
7
7
|
import { logger } from "../utils/logger.js";
|
|
8
8
|
import type { InMemoryMCPServerConfig, InMemoryToolInfo } from "../types/mcp-types.js";
|
|
9
|
+
import type { ToolArgs, ToolContext as CoreToolContext, ToolResult, SimpleTool as CoreSimpleTool } from "../types/tools.js";
|
|
10
|
+
import type { JsonValue } from "../types/common.js";
|
|
9
11
|
/**
|
|
10
12
|
* Context provided to tools during execution
|
|
13
|
+
* Extends the core ToolContext with SDK-specific features
|
|
11
14
|
*/
|
|
12
|
-
export interface ToolContext {
|
|
15
|
+
export interface ToolContext extends CoreToolContext {
|
|
13
16
|
/**
|
|
14
17
|
* Current session ID
|
|
15
18
|
*/
|
|
16
19
|
sessionId: string;
|
|
17
|
-
/**
|
|
18
|
-
* User ID if available
|
|
19
|
-
*/
|
|
20
|
-
userId?: string;
|
|
21
20
|
/**
|
|
22
21
|
* AI provider being used
|
|
23
22
|
*/
|
|
@@ -29,7 +28,7 @@ export interface ToolContext {
|
|
|
29
28
|
/**
|
|
30
29
|
* Call another tool
|
|
31
30
|
*/
|
|
32
|
-
callTool?: (name: string, args:
|
|
31
|
+
callTool?: (name: string, args: ToolArgs) => Promise<ToolResult>;
|
|
33
32
|
/**
|
|
34
33
|
* Logger instance
|
|
35
34
|
*/
|
|
@@ -37,8 +36,9 @@ export interface ToolContext {
|
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
39
38
|
* Simple tool interface for SDK users
|
|
39
|
+
* Extends the core SimpleTool with specific types
|
|
40
40
|
*/
|
|
41
|
-
export interface SimpleTool {
|
|
41
|
+
export interface SimpleTool<TArgs = ToolArgs, TResult = JsonValue> extends Omit<CoreSimpleTool<TArgs, TResult>, "execute"> {
|
|
42
42
|
/**
|
|
43
43
|
* Tool description that helps AI understand when to use it
|
|
44
44
|
*/
|
|
@@ -50,7 +50,7 @@ export interface SimpleTool {
|
|
|
50
50
|
/**
|
|
51
51
|
* Tool execution function
|
|
52
52
|
*/
|
|
53
|
-
execute: (args:
|
|
53
|
+
execute: (args: TArgs, context?: ToolContext) => Promise<TResult> | TResult;
|
|
54
54
|
/**
|
|
55
55
|
* Optional metadata
|
|
56
56
|
*/
|
|
@@ -58,7 +58,9 @@ export interface SimpleTool {
|
|
|
58
58
|
category?: string;
|
|
59
59
|
version?: string;
|
|
60
60
|
author?: string;
|
|
61
|
-
|
|
61
|
+
tags?: string[];
|
|
62
|
+
documentation?: string;
|
|
63
|
+
[key: string]: JsonValue | undefined;
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
/**
|
|
@@ -76,18 +78,20 @@ export declare function createMCPServerFromTools(serverId: string, tools: Record
|
|
|
76
78
|
title?: string;
|
|
77
79
|
description?: string;
|
|
78
80
|
category?: string;
|
|
79
|
-
|
|
81
|
+
version?: string;
|
|
82
|
+
author?: string;
|
|
83
|
+
[key: string]: JsonValue | undefined;
|
|
80
84
|
}): InMemoryMCPServerConfig;
|
|
81
85
|
/**
|
|
82
86
|
* Helper to create a tool with type safety
|
|
83
87
|
*/
|
|
84
|
-
export declare function createTool<TParams =
|
|
88
|
+
export declare function createTool<TParams = ToolArgs>(config: SimpleTool): SimpleTool;
|
|
85
89
|
/**
|
|
86
90
|
* Helper to create a tool with typed parameters
|
|
87
91
|
*/
|
|
88
92
|
export declare function createTypedTool<TParams extends z.ZodSchema>(config: Omit<SimpleTool, "execute"> & {
|
|
89
93
|
parameters: TParams;
|
|
90
|
-
execute: (args: z.infer<TParams>, context?: ToolContext) => Promise<
|
|
94
|
+
execute: (args: z.infer<TParams>, context?: ToolContext) => Promise<JsonValue> | JsonValue;
|
|
91
95
|
}): SimpleTool;
|
|
92
96
|
/**
|
|
93
97
|
* Validate tool configuration with detailed error messages
|
|
@@ -41,8 +41,9 @@ export function convertToMCPTool(simpleTool) {
|
|
|
41
41
|
return {
|
|
42
42
|
description: simpleTool.description,
|
|
43
43
|
execute: async (params) => {
|
|
44
|
+
const typedParams = params;
|
|
44
45
|
try {
|
|
45
|
-
const result = await simpleTool.execute(
|
|
46
|
+
const result = await simpleTool.execute(typedParams);
|
|
46
47
|
return {
|
|
47
48
|
success: true,
|
|
48
49
|
data: result,
|
|
@@ -134,7 +135,7 @@ export function validateTool(name, tool) {
|
|
|
134
135
|
// Validate execute function with signature guidance
|
|
135
136
|
if (typeof tool.execute !== "function") {
|
|
136
137
|
throw new Error(`Tool '${name}' must have an execute function. ` +
|
|
137
|
-
`Expected signature: async (params?:
|
|
138
|
+
`Expected signature: async (params?: ToolArgs) => Promise<unknown>. ` +
|
|
138
139
|
`Received: ${typeof tool.execute}. ` +
|
|
139
140
|
`Example: { execute: async (params) => { return { success: true, data: result }; } }`);
|
|
140
141
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UnknownRecord, Unknown } from "../types/common.js";
|
|
1
2
|
export interface StreamingSession {
|
|
2
3
|
id: string;
|
|
3
4
|
connectionId: string;
|
|
@@ -57,12 +58,12 @@ export interface StreamingChannel {
|
|
|
57
58
|
type: "ai-response" | "mcp-tool" | "chat" | "notification";
|
|
58
59
|
status: "open" | "closed" | "error";
|
|
59
60
|
buffer: StreamingBuffer;
|
|
60
|
-
onData: (data:
|
|
61
|
+
onData: (data: Unknown) => void;
|
|
61
62
|
onError: (error: Error) => void;
|
|
62
63
|
onClose: () => void;
|
|
63
64
|
}
|
|
64
65
|
export interface StreamingBuffer {
|
|
65
|
-
data:
|
|
66
|
+
data: Unknown[];
|
|
66
67
|
maxSize: number;
|
|
67
68
|
currentSize: number;
|
|
68
69
|
flushThreshold: number;
|
|
@@ -92,7 +93,7 @@ export interface WebSocketMessage {
|
|
|
92
93
|
connectionId: string;
|
|
93
94
|
roomId?: string;
|
|
94
95
|
timestamp: number;
|
|
95
|
-
data:
|
|
96
|
+
data: Unknown;
|
|
96
97
|
metadata?: {
|
|
97
98
|
provider?: string;
|
|
98
99
|
model?: string;
|
|
@@ -151,5 +152,5 @@ export interface ConnectionInfo {
|
|
|
151
152
|
lastActivity: number;
|
|
152
153
|
rooms: Set<string>;
|
|
153
154
|
subscriptions: Set<string>;
|
|
154
|
-
metadata:
|
|
155
|
+
metadata: UnknownRecord;
|
|
155
156
|
}
|
|
@@ -18,7 +18,7 @@ export declare class NeuroLinkWebSocketServer extends EventEmitter {
|
|
|
18
18
|
broadcastToRoom(roomId: string, message: WebSocketMessage): void;
|
|
19
19
|
createStreamingChannel(connectionId: string, channelId: string): StreamingChannel;
|
|
20
20
|
destroyStreamingChannel(channelId: string): void;
|
|
21
|
-
|
|
21
|
+
sendMessage(connectionId: string, message: WebSocketMessage): boolean;
|
|
22
22
|
private sendError;
|
|
23
23
|
private updateLastActivity;
|
|
24
24
|
private handleHeartbeat;
|
|
@@ -44,7 +44,7 @@ export class NeuroLinkWebSocketServer extends EventEmitter {
|
|
|
44
44
|
}
|
|
45
45
|
const connectionId = randomUUID();
|
|
46
46
|
const userAgent = request.headers["user-agent"];
|
|
47
|
-
const ipAddress = request.socket
|
|
47
|
+
const ipAddress = request.socket?.remoteAddress;
|
|
48
48
|
// Store connection
|
|
49
49
|
this.connections.set(connectionId, ws);
|
|
50
50
|
this.connectionInfo.set(connectionId, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
2
|
-
import { metrics, trace } from "@opentelemetry/api";
|
|
2
|
+
import { metrics, trace, } from "@opentelemetry/api";
|
|
3
3
|
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
|
|
4
4
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
5
5
|
import { Resource } from "@opentelemetry/resources";
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI-specific type definitions for NeuroLink
|
|
3
|
+
* Replaces 'any' types in CLI commands and arguments
|
|
4
|
+
*/
|
|
5
|
+
import type { UnknownRecord, JsonValue } from "./common.js";
|
|
6
|
+
import type { AnalyticsData, EvaluationData, TokenUsage } from "./providers.js";
|
|
7
|
+
import type { ToolCall, ToolResult } from "./tools.js";
|
|
8
|
+
/**
|
|
9
|
+
* Base command arguments interface
|
|
10
|
+
*/
|
|
11
|
+
export interface BaseCommandArgs {
|
|
12
|
+
/** Enable debug output */
|
|
13
|
+
debug?: boolean;
|
|
14
|
+
/** Output format */
|
|
15
|
+
format?: "text" | "json" | "table";
|
|
16
|
+
/** Verbose output */
|
|
17
|
+
verbose?: boolean;
|
|
18
|
+
/** Quiet mode */
|
|
19
|
+
quiet?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Generate command arguments
|
|
23
|
+
*/
|
|
24
|
+
export interface GenerateCommandArgs extends BaseCommandArgs {
|
|
25
|
+
/** Input text or prompt */
|
|
26
|
+
input?: string;
|
|
27
|
+
/** AI provider to use */
|
|
28
|
+
provider?: string;
|
|
29
|
+
/** Model name */
|
|
30
|
+
model?: string;
|
|
31
|
+
/** System prompt */
|
|
32
|
+
system?: string;
|
|
33
|
+
/** Temperature setting */
|
|
34
|
+
temperature?: number;
|
|
35
|
+
/** Maximum tokens */
|
|
36
|
+
maxTokens?: number;
|
|
37
|
+
/** Enable analytics */
|
|
38
|
+
analytics?: boolean;
|
|
39
|
+
/** Enable evaluation */
|
|
40
|
+
evaluation?: boolean;
|
|
41
|
+
/** Context data */
|
|
42
|
+
context?: string;
|
|
43
|
+
/** Disable tools */
|
|
44
|
+
disableTools?: boolean;
|
|
45
|
+
/** Maximum steps for multi-turn */
|
|
46
|
+
maxSteps?: number;
|
|
47
|
+
/** Output file */
|
|
48
|
+
output?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Stream command arguments
|
|
52
|
+
*/
|
|
53
|
+
export interface StreamCommandArgs extends BaseCommandArgs {
|
|
54
|
+
/** Input text or prompt */
|
|
55
|
+
input?: string;
|
|
56
|
+
/** AI provider to use */
|
|
57
|
+
provider?: string;
|
|
58
|
+
/** Model name */
|
|
59
|
+
model?: string;
|
|
60
|
+
/** System prompt */
|
|
61
|
+
system?: string;
|
|
62
|
+
/** Temperature setting */
|
|
63
|
+
temperature?: number;
|
|
64
|
+
/** Maximum tokens */
|
|
65
|
+
maxTokens?: number;
|
|
66
|
+
/** Disable tools */
|
|
67
|
+
disableTools?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* MCP command arguments
|
|
71
|
+
*/
|
|
72
|
+
export interface MCPCommandArgs extends BaseCommandArgs {
|
|
73
|
+
/** MCP server name */
|
|
74
|
+
server?: string;
|
|
75
|
+
/** Tool name to execute */
|
|
76
|
+
tool?: string;
|
|
77
|
+
/** Tool parameters as JSON string */
|
|
78
|
+
params?: string;
|
|
79
|
+
/** List available tools */
|
|
80
|
+
list?: boolean;
|
|
81
|
+
/** Discover MCP servers */
|
|
82
|
+
discover?: boolean;
|
|
83
|
+
/** Show server information */
|
|
84
|
+
info?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Ollama command arguments
|
|
88
|
+
*/
|
|
89
|
+
export interface OllamaCommandArgs extends BaseCommandArgs {
|
|
90
|
+
/** Ollama model name */
|
|
91
|
+
model?: string;
|
|
92
|
+
/** List available models */
|
|
93
|
+
list?: boolean;
|
|
94
|
+
/** Pull a model */
|
|
95
|
+
pull?: boolean;
|
|
96
|
+
/** Remove a model */
|
|
97
|
+
remove?: boolean;
|
|
98
|
+
/** Show model information */
|
|
99
|
+
show?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Provider status command arguments
|
|
103
|
+
*/
|
|
104
|
+
export interface ProviderStatusArgs extends BaseCommandArgs {
|
|
105
|
+
/** Specific provider to check */
|
|
106
|
+
provider?: string;
|
|
107
|
+
/** Check all providers */
|
|
108
|
+
all?: boolean;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* CLI command result
|
|
112
|
+
*/
|
|
113
|
+
export interface CommandResult {
|
|
114
|
+
/** Command success status */
|
|
115
|
+
success: boolean;
|
|
116
|
+
/** Result data */
|
|
117
|
+
data?: unknown;
|
|
118
|
+
/** Error message if failed */
|
|
119
|
+
error?: string;
|
|
120
|
+
/** Output content */
|
|
121
|
+
content?: string;
|
|
122
|
+
/** Execution metadata */
|
|
123
|
+
metadata?: {
|
|
124
|
+
executionTime?: number;
|
|
125
|
+
timestamp?: number;
|
|
126
|
+
command?: string;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Generate command result
|
|
131
|
+
*/
|
|
132
|
+
export interface GenerateResult extends CommandResult {
|
|
133
|
+
content: string;
|
|
134
|
+
provider?: string;
|
|
135
|
+
model?: string;
|
|
136
|
+
usage?: TokenUsage;
|
|
137
|
+
responseTime?: number;
|
|
138
|
+
toolCalls?: ToolCall[];
|
|
139
|
+
toolResults?: ToolResult[];
|
|
140
|
+
analytics?: AnalyticsData;
|
|
141
|
+
evaluation?: EvaluationData;
|
|
142
|
+
toolsUsed?: string[];
|
|
143
|
+
toolExecutions?: Array<{
|
|
144
|
+
toolName: string;
|
|
145
|
+
args: UnknownRecord;
|
|
146
|
+
result: unknown;
|
|
147
|
+
executionTime: number;
|
|
148
|
+
}>;
|
|
149
|
+
enhancedWithTools?: boolean;
|
|
150
|
+
availableTools?: Array<{
|
|
151
|
+
name: string;
|
|
152
|
+
description: string;
|
|
153
|
+
}>;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Stream result chunk
|
|
157
|
+
*/
|
|
158
|
+
export interface StreamChunk {
|
|
159
|
+
content?: string;
|
|
160
|
+
delta?: string;
|
|
161
|
+
done?: boolean;
|
|
162
|
+
metadata?: UnknownRecord;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* CLI output formatting options
|
|
166
|
+
*/
|
|
167
|
+
export interface OutputOptions {
|
|
168
|
+
format: "text" | "json" | "table";
|
|
169
|
+
pretty?: boolean;
|
|
170
|
+
color?: boolean;
|
|
171
|
+
compact?: boolean;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Command handler function type
|
|
175
|
+
*/
|
|
176
|
+
export type CommandHandler<TArgs = BaseCommandArgs, TResult = CommandResult> = (args: TArgs) => Promise<TResult>;
|
|
177
|
+
/**
|
|
178
|
+
* Command definition
|
|
179
|
+
*/
|
|
180
|
+
export interface CommandDefinition<TArgs = BaseCommandArgs> {
|
|
181
|
+
name: string;
|
|
182
|
+
description: string;
|
|
183
|
+
aliases?: string[];
|
|
184
|
+
args?: {
|
|
185
|
+
[K in keyof TArgs]: {
|
|
186
|
+
type: "string" | "number" | "boolean";
|
|
187
|
+
description: string;
|
|
188
|
+
required?: boolean;
|
|
189
|
+
default?: TArgs[K];
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
handler: CommandHandler<TArgs>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* CLI context
|
|
196
|
+
*/
|
|
197
|
+
export interface CLIContext {
|
|
198
|
+
cwd: string;
|
|
199
|
+
args: string[];
|
|
200
|
+
env: NodeJS.ProcessEnv;
|
|
201
|
+
exitCode?: number;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Color mapping for CLI output
|
|
205
|
+
*/
|
|
206
|
+
export interface ColorMap {
|
|
207
|
+
[severity: string]: {
|
|
208
|
+
color: string;
|
|
209
|
+
symbol?: string;
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Display severity colors (for evaluation display)
|
|
214
|
+
*/
|
|
215
|
+
export interface SeverityColors {
|
|
216
|
+
[key: string]: {
|
|
217
|
+
color: string;
|
|
218
|
+
symbol: string;
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* JSON output structure
|
|
223
|
+
*/
|
|
224
|
+
export interface JSONOutput {
|
|
225
|
+
success: boolean;
|
|
226
|
+
data?: JsonValue;
|
|
227
|
+
error?: string;
|
|
228
|
+
metadata?: {
|
|
229
|
+
timestamp: number;
|
|
230
|
+
command: string;
|
|
231
|
+
version?: string;
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Console override for quiet mode
|
|
236
|
+
*/
|
|
237
|
+
export interface ConsoleOverride {
|
|
238
|
+
[method: string]: (() => void) | undefined;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Type guard for generate result
|
|
242
|
+
*/
|
|
243
|
+
export declare function isGenerateResult(value: unknown): value is GenerateResult;
|
|
244
|
+
/**
|
|
245
|
+
* Type guard for command result
|
|
246
|
+
*/
|
|
247
|
+
export declare function isCommandResult(value: unknown): value is CommandResult;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI-specific type definitions for NeuroLink
|
|
3
|
+
* Replaces 'any' types in CLI commands and arguments
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Type guard for generate result
|
|
7
|
+
*/
|
|
8
|
+
export function isGenerateResult(value) {
|
|
9
|
+
return (typeof value === "object" &&
|
|
10
|
+
value !== null &&
|
|
11
|
+
"content" in value &&
|
|
12
|
+
typeof value.content === "string");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Type guard for command result
|
|
16
|
+
*/
|
|
17
|
+
export function isCommandResult(value) {
|
|
18
|
+
return (typeof value === "object" &&
|
|
19
|
+
value !== null &&
|
|
20
|
+
"success" in value &&
|
|
21
|
+
typeof value.success === "boolean");
|
|
22
|
+
}
|