@mcp-use/cli 1.0.0 → 1.0.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/dist/InputPrompt.d.ts +13 -0
- package/dist/InputPrompt.js +188 -0
- package/dist/MultilineInput.d.ts +13 -0
- package/dist/MultilineInput.js +154 -0
- package/dist/MultilineTextInput.d.ts +11 -0
- package/dist/MultilineTextInput.js +97 -0
- package/dist/PasteAwareInput.d.ts +13 -0
- package/dist/PasteAwareInput.js +183 -0
- package/dist/SimpleMultilineInput.d.ts +11 -0
- package/dist/SimpleMultilineInput.js +125 -0
- package/dist/app.d.ts +1 -5
- package/dist/app.js +291 -186
- package/dist/cli.js +2 -5
- package/dist/commands.d.ts +15 -30
- package/dist/commands.js +308 -568
- package/dist/components/AsciiLogo.d.ts +2 -0
- package/dist/components/AsciiLogo.js +7 -0
- package/dist/components/Footer.d.ts +5 -0
- package/dist/components/Footer.js +19 -0
- package/dist/components/InputPrompt.d.ts +13 -0
- package/dist/components/InputPrompt.js +188 -0
- package/dist/components/Messages.d.ts +21 -0
- package/dist/components/Messages.js +80 -0
- package/dist/components/ServerStatus.d.ts +7 -0
- package/dist/components/ServerStatus.js +36 -0
- package/dist/components/Spinner.d.ts +16 -0
- package/dist/components/Spinner.js +63 -0
- package/dist/components/ToolStatus.d.ts +8 -0
- package/dist/components/ToolStatus.js +33 -0
- package/dist/components/textInput.d.ts +1 -0
- package/dist/components/textInput.js +1 -0
- package/dist/logger.d.ts +10 -0
- package/dist/logger.js +48 -0
- package/dist/mcp-service.d.ts +5 -4
- package/dist/mcp-service.js +98 -207
- package/dist/services/agent-service.d.ts +56 -0
- package/dist/services/agent-service.js +203 -0
- package/dist/services/cli-service.d.ts +132 -0
- package/dist/services/cli-service.js +591 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.js +4 -0
- package/dist/services/llm-service.d.ts +174 -0
- package/dist/services/llm-service.js +567 -0
- package/dist/services/mcp-config-service.d.ts +69 -0
- package/dist/services/mcp-config-service.js +426 -0
- package/dist/services/mcp-service.d.ts +1 -0
- package/dist/services/mcp-service.js +1 -0
- package/dist/services/utility-service.d.ts +47 -0
- package/dist/services/utility-service.js +208 -0
- package/dist/storage.js +4 -4
- package/dist/types.d.ts +30 -0
- package/dist/types.js +1 -0
- package/package.json +22 -8
- package/readme.md +68 -39
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { CommandResult } from '../types.js';
|
|
2
|
+
import type { ToolCall } from '../types.js';
|
|
3
|
+
export declare class CLIService {
|
|
4
|
+
private isInitialized;
|
|
5
|
+
private agentService;
|
|
6
|
+
private llmService;
|
|
7
|
+
private mcpConfigService;
|
|
8
|
+
private utilityService;
|
|
9
|
+
private commandRegistry;
|
|
10
|
+
/**
|
|
11
|
+
* Initializes the CLIService and its dependencies. This acts as the
|
|
12
|
+
* composition root for the application's services.
|
|
13
|
+
*/
|
|
14
|
+
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Registers all available commands in the command registry.
|
|
17
|
+
* This creates a centralized mapping of command names to their handlers.
|
|
18
|
+
*/
|
|
19
|
+
private registerCommands;
|
|
20
|
+
/**
|
|
21
|
+
* Initializes the CLI service, ensuring the agent is ready.
|
|
22
|
+
* This method is idempotent and will only run once.
|
|
23
|
+
*/
|
|
24
|
+
initialize(): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Initializes the underlying MCP agent via the AgentService.
|
|
27
|
+
* If initialization fails, an error is logged, but the CLI can continue
|
|
28
|
+
* to operate for command-line tasks.
|
|
29
|
+
*/
|
|
30
|
+
initializeAgent(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Re-initializes the agent. This is useful when the configuration
|
|
33
|
+
* (e.g., model or servers) has changed.
|
|
34
|
+
*/
|
|
35
|
+
refreshAgent(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if the input is a slash command.
|
|
38
|
+
* @param input - The user input to check
|
|
39
|
+
* @returns True if the input starts with /
|
|
40
|
+
*/
|
|
41
|
+
private isCommand;
|
|
42
|
+
/**
|
|
43
|
+
* Handles command execution by routing to the appropriate service.
|
|
44
|
+
* @param input - The full command input including the slash
|
|
45
|
+
* @returns A promise that resolves to the command result
|
|
46
|
+
*/
|
|
47
|
+
private handleCommand;
|
|
48
|
+
/**
|
|
49
|
+
* Processes a user's message. It determines if the message is a command
|
|
50
|
+
* or a prompt for the agent and routes it accordingly. It also handles
|
|
51
|
+
* special input modes like API key entry or server configuration.
|
|
52
|
+
* @param message The raw input string from the user.
|
|
53
|
+
* @param isApiKeyInput True if the input is an API key.
|
|
54
|
+
* @param pendingProvider The provider for which the API key is being entered.
|
|
55
|
+
* @param pendingModel The model for which the API key is being entered.
|
|
56
|
+
* @param isServerConfigInput True if the input is part of the server config flow.
|
|
57
|
+
* @param serverConfigStep The current step in the server configuration flow.
|
|
58
|
+
* @param serverConfig The server configuration object being built.
|
|
59
|
+
* @returns A promise that resolves to the result of the message processing.
|
|
60
|
+
*/
|
|
61
|
+
sendMessage(message: string, isApiKeyInput?: boolean, pendingProvider?: string, pendingModel?: string, isServerConfigInput?: boolean, serverConfigStep?: string, serverConfig?: any): AsyncGenerator<{
|
|
62
|
+
response?: string;
|
|
63
|
+
toolCalls?: ToolCall[];
|
|
64
|
+
thought?: string;
|
|
65
|
+
isCommand?: boolean;
|
|
66
|
+
commandResult?: CommandResult;
|
|
67
|
+
done: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Returns an example model name for a given provider.
|
|
71
|
+
* @param provider The name of the LLM provider.
|
|
72
|
+
* @returns An example model name string.
|
|
73
|
+
*/
|
|
74
|
+
private getExampleModel;
|
|
75
|
+
/**
|
|
76
|
+
* Checks if the CLI service has been initialized.
|
|
77
|
+
* @returns True if the service is initialized, false otherwise.
|
|
78
|
+
*/
|
|
79
|
+
isReady(): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Gets a formatted string representing the current model.
|
|
82
|
+
* @returns A string like "provider/model-name" or a status message.
|
|
83
|
+
*/
|
|
84
|
+
getCurrentModel(): string;
|
|
85
|
+
/**
|
|
86
|
+
* Gets a list of all configured server names from persistent storage.
|
|
87
|
+
* @returns An array of configured server names.
|
|
88
|
+
*/
|
|
89
|
+
getConfiguredServers(): string[];
|
|
90
|
+
/**
|
|
91
|
+
* Gets a list of currently connected server names.
|
|
92
|
+
* @returns An array of connected server names.
|
|
93
|
+
*/
|
|
94
|
+
getConnectedServers(): string[];
|
|
95
|
+
/**
|
|
96
|
+
* Gets the list of available tools from the agent.
|
|
97
|
+
* @returns A promise that resolves to an object containing the tools or an error.
|
|
98
|
+
*/
|
|
99
|
+
getAvailableTools(): Promise<{
|
|
100
|
+
tools: any[];
|
|
101
|
+
error?: string;
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* Handles the /servers command by combining configuration and connection status.
|
|
105
|
+
* @returns A CommandResult with the server list including connection status
|
|
106
|
+
*/
|
|
107
|
+
private handleListServersCommand;
|
|
108
|
+
/**
|
|
109
|
+
* Handles the base /server command to show subcommands.
|
|
110
|
+
* @param args - Command arguments
|
|
111
|
+
* @returns A CommandResult with help information
|
|
112
|
+
*/
|
|
113
|
+
private handleServerCommand;
|
|
114
|
+
/**
|
|
115
|
+
* Handles the /server add subcommand.
|
|
116
|
+
* @returns A CommandResult to start server configuration
|
|
117
|
+
*/
|
|
118
|
+
private handleServerAddCommand;
|
|
119
|
+
/**
|
|
120
|
+
* Handles the /server connect subcommand.
|
|
121
|
+
* @param args - Array where args[0] is the server name
|
|
122
|
+
* @returns A CommandResult with connection status
|
|
123
|
+
*/
|
|
124
|
+
private handleServerConnectCommand;
|
|
125
|
+
/**
|
|
126
|
+
* Handles the /server disconnect subcommand.
|
|
127
|
+
* @param args - Array where args[0] is the server name
|
|
128
|
+
* @returns A CommandResult with disconnection status
|
|
129
|
+
*/
|
|
130
|
+
private handleServerDisconnectCommand;
|
|
131
|
+
}
|
|
132
|
+
export declare const cliService: CLIService;
|