@zds-ai/cli 0.1.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/LICENSE +21 -0
- package/README.md +497 -0
- package/dist/agent/grok-agent.d.ts +250 -0
- package/dist/agent/grok-agent.js +2480 -0
- package/dist/agent/grok-agent.js.map +1 -0
- package/dist/agent/index.d.ts +14 -0
- package/dist/agent/index.js +136 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/commands/mcp.d.ts +2 -0
- package/dist/commands/mcp.js +239 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/grok/client.d.ts +55 -0
- package/dist/grok/client.js +276 -0
- package/dist/grok/client.js.map +1 -0
- package/dist/grok/tools.d.ts +8 -0
- package/dist/grok/tools.js +878 -0
- package/dist/grok/tools.js.map +1 -0
- package/dist/hooks/use-enhanced-input.d.ts +38 -0
- package/dist/hooks/use-enhanced-input.js +228 -0
- package/dist/hooks/use-enhanced-input.js.map +1 -0
- package/dist/hooks/use-input-handler.d.ts +36 -0
- package/dist/hooks/use-input-handler.js +1099 -0
- package/dist/hooks/use-input-handler.js.map +1 -0
- package/dist/hooks/use-input-history.d.ts +9 -0
- package/dist/hooks/use-input-history.js +61 -0
- package/dist/hooks/use-input-history.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +869 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/client.d.ts +41 -0
- package/dist/mcp/client.js +224 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/config.d.ts +13 -0
- package/dist/mcp/config.js +56 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/transports.d.ts +53 -0
- package/dist/mcp/transports.js +256 -0
- package/dist/mcp/transports.js.map +1 -0
- package/dist/tools/character-tool.d.ts +27 -0
- package/dist/tools/character-tool.js +194 -0
- package/dist/tools/character-tool.js.map +1 -0
- package/dist/tools/clear-cache-tool.d.ts +14 -0
- package/dist/tools/clear-cache-tool.js +82 -0
- package/dist/tools/clear-cache-tool.js.map +1 -0
- package/dist/tools/confirmation-tool.d.ts +16 -0
- package/dist/tools/confirmation-tool.js +72 -0
- package/dist/tools/confirmation-tool.js.map +1 -0
- package/dist/tools/env-tool.d.ts +17 -0
- package/dist/tools/env-tool.js +89 -0
- package/dist/tools/env-tool.js.map +1 -0
- package/dist/tools/file-conversion-tool.d.ts +16 -0
- package/dist/tools/file-conversion-tool.js +181 -0
- package/dist/tools/file-conversion-tool.js.map +1 -0
- package/dist/tools/image-tool.d.ts +22 -0
- package/dist/tools/image-tool.js +268 -0
- package/dist/tools/image-tool.js.map +1 -0
- package/dist/tools/index.d.ts +14 -0
- package/dist/tools/index.js +15 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/internet-tool.d.ts +11 -0
- package/dist/tools/internet-tool.js +108 -0
- package/dist/tools/internet-tool.js.map +1 -0
- package/dist/tools/introspect-tool.d.ts +11 -0
- package/dist/tools/introspect-tool.js +243 -0
- package/dist/tools/introspect-tool.js.map +1 -0
- package/dist/tools/morph-editor.d.ts +38 -0
- package/dist/tools/morph-editor.js +318 -0
- package/dist/tools/morph-editor.js.map +1 -0
- package/dist/tools/restart-tool.d.ts +7 -0
- package/dist/tools/restart-tool.js +24 -0
- package/dist/tools/restart-tool.js.map +1 -0
- package/dist/tools/search.d.ts +71 -0
- package/dist/tools/search.js +340 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/task-tool.d.ts +19 -0
- package/dist/tools/task-tool.js +115 -0
- package/dist/tools/task-tool.js.map +1 -0
- package/dist/tools/text-editor.d.ts +35 -0
- package/dist/tools/text-editor.js +669 -0
- package/dist/tools/text-editor.js.map +1 -0
- package/dist/tools/tool-discovery.d.ts +20 -0
- package/dist/tools/tool-discovery.js +45 -0
- package/dist/tools/tool-discovery.js.map +1 -0
- package/dist/tools/zsh.d.ts +13 -0
- package/dist/tools/zsh.js +168 -0
- package/dist/tools/zsh.js.map +1 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/app.d.ts +7 -0
- package/dist/ui/app.js +99 -0
- package/dist/ui/app.js.map +1 -0
- package/dist/ui/components/active-task-status.d.ts +7 -0
- package/dist/ui/components/active-task-status.js +37 -0
- package/dist/ui/components/active-task-status.js.map +1 -0
- package/dist/ui/components/api-key-input.d.ts +7 -0
- package/dist/ui/components/api-key-input.js +80 -0
- package/dist/ui/components/api-key-input.js.map +1 -0
- package/dist/ui/components/backend-status.d.ts +7 -0
- package/dist/ui/components/backend-status.js +85 -0
- package/dist/ui/components/backend-status.js.map +1 -0
- package/dist/ui/components/chat-history.d.ts +8 -0
- package/dist/ui/components/chat-history.js +187 -0
- package/dist/ui/components/chat-history.js.map +1 -0
- package/dist/ui/components/chat-input.d.ts +9 -0
- package/dist/ui/components/chat-input.js +63 -0
- package/dist/ui/components/chat-input.js.map +1 -0
- package/dist/ui/components/chat-interface.d.ts +9 -0
- package/dist/ui/components/chat-interface.js +389 -0
- package/dist/ui/components/chat-interface.js.map +1 -0
- package/dist/ui/components/command-suggestions.d.ts +17 -0
- package/dist/ui/components/command-suggestions.js +22 -0
- package/dist/ui/components/command-suggestions.js.map +1 -0
- package/dist/ui/components/confirmation-dialog.d.ts +11 -0
- package/dist/ui/components/confirmation-dialog.js +105 -0
- package/dist/ui/components/confirmation-dialog.js.map +1 -0
- package/dist/ui/components/context-status.d.ts +7 -0
- package/dist/ui/components/context-status.js +36 -0
- package/dist/ui/components/context-status.js.map +1 -0
- package/dist/ui/components/diff-renderer.d.ts +13 -0
- package/dist/ui/components/diff-renderer.js +206 -0
- package/dist/ui/components/diff-renderer.js.map +1 -0
- package/dist/ui/components/loading-spinner.d.ts +8 -0
- package/dist/ui/components/loading-spinner.js +64 -0
- package/dist/ui/components/loading-spinner.js.map +1 -0
- package/dist/ui/components/mcp-status.d.ts +5 -0
- package/dist/ui/components/mcp-status.js +57 -0
- package/dist/ui/components/mcp-status.js.map +1 -0
- package/dist/ui/components/model-selection.d.ts +12 -0
- package/dist/ui/components/model-selection.js +17 -0
- package/dist/ui/components/model-selection.js.map +1 -0
- package/dist/ui/components/mood-status.d.ts +7 -0
- package/dist/ui/components/mood-status.js +34 -0
- package/dist/ui/components/mood-status.js.map +1 -0
- package/dist/ui/components/persona-status.d.ts +7 -0
- package/dist/ui/components/persona-status.js +34 -0
- package/dist/ui/components/persona-status.js.map +1 -0
- package/dist/ui/shared/max-sized-box.d.ts +8 -0
- package/dist/ui/shared/max-sized-box.js +6 -0
- package/dist/ui/shared/max-sized-box.js.map +1 -0
- package/dist/ui/utils/code-colorizer.d.ts +2 -0
- package/dist/ui/utils/code-colorizer.js +7 -0
- package/dist/ui/utils/code-colorizer.js.map +1 -0
- package/dist/ui/utils/colors.d.ts +14 -0
- package/dist/ui/utils/colors.js +15 -0
- package/dist/ui/utils/colors.js.map +1 -0
- package/dist/ui/utils/markdown-renderer.d.ts +4 -0
- package/dist/ui/utils/markdown-renderer.js +40 -0
- package/dist/ui/utils/markdown-renderer.js.map +1 -0
- package/dist/utils/auth-helper.d.ts +63 -0
- package/dist/utils/auth-helper.js +129 -0
- package/dist/utils/auth-helper.js.map +1 -0
- package/dist/utils/chat-history-manager-sqlite.d.ts +92 -0
- package/dist/utils/chat-history-manager-sqlite.js +334 -0
- package/dist/utils/chat-history-manager-sqlite.js.map +1 -0
- package/dist/utils/chat-history-manager.d.ts +87 -0
- package/dist/utils/chat-history-manager.js +273 -0
- package/dist/utils/chat-history-manager.js.map +1 -0
- package/dist/utils/chat-history-manager.json-backup.d.ts +69 -0
- package/dist/utils/chat-history-manager.json-backup.js +215 -0
- package/dist/utils/chat-history-manager.json-backup.js.map +1 -0
- package/dist/utils/confirmation-service.d.ts +46 -0
- package/dist/utils/confirmation-service.js +165 -0
- package/dist/utils/confirmation-service.js.map +1 -0
- package/dist/utils/custom-instructions.d.ts +1 -0
- package/dist/utils/custom-instructions.js +30 -0
- package/dist/utils/custom-instructions.js.map +1 -0
- package/dist/utils/database-connection.d.ts +27 -0
- package/dist/utils/database-connection.js +81 -0
- package/dist/utils/database-connection.js.map +1 -0
- package/dist/utils/database-schema.d.ts +17 -0
- package/dist/utils/database-schema.js +93 -0
- package/dist/utils/database-schema.js.map +1 -0
- package/dist/utils/error-logger.d.ts +13 -0
- package/dist/utils/error-logger.js +56 -0
- package/dist/utils/error-logger.js.map +1 -0
- package/dist/utils/hook-executor.d.ts +59 -0
- package/dist/utils/hook-executor.js +351 -0
- package/dist/utils/hook-executor.js.map +1 -0
- package/dist/utils/model-config.d.ts +28 -0
- package/dist/utils/model-config.js +42 -0
- package/dist/utils/model-config.js.map +1 -0
- package/dist/utils/path-utils.d.ts +4 -0
- package/dist/utils/path-utils.js +12 -0
- package/dist/utils/path-utils.js.map +1 -0
- package/dist/utils/settings-manager.d.ts +169 -0
- package/dist/utils/settings-manager.js +403 -0
- package/dist/utils/settings-manager.js.map +1 -0
- package/dist/utils/settings.d.ts +1 -0
- package/dist/utils/settings.js +4 -0
- package/dist/utils/settings.js.map +1 -0
- package/dist/utils/slash-commands.d.ts +25 -0
- package/dist/utils/slash-commands.js +454 -0
- package/dist/utils/slash-commands.js.map +1 -0
- package/dist/utils/startup-hook.d.ts +13 -0
- package/dist/utils/startup-hook.js +44 -0
- package/dist/utils/startup-hook.js.map +1 -0
- package/dist/utils/text-utils.d.ts +80 -0
- package/dist/utils/text-utils.js +182 -0
- package/dist/utils/text-utils.js.map +1 -0
- package/dist/utils/token-counter.d.ts +33 -0
- package/dist/utils/token-counter.js +78 -0
- package/dist/utils/token-counter.js.map +1 -0
- package/package.json +102 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
import * as path from "path";
|
|
6
|
+
export class StdioTransport {
|
|
7
|
+
config;
|
|
8
|
+
transport;
|
|
9
|
+
process;
|
|
10
|
+
debugLogFd;
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this.config = config;
|
|
13
|
+
if (!config.command) {
|
|
14
|
+
throw new Error('Command is required for stdio transport');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async connect() {
|
|
18
|
+
// Create transport with environment variables to suppress verbose output
|
|
19
|
+
const env = {
|
|
20
|
+
...process.env,
|
|
21
|
+
...this.config.env,
|
|
22
|
+
// Try to suppress verbose output from mcp-remote
|
|
23
|
+
MCP_REMOTE_QUIET: '1',
|
|
24
|
+
MCP_REMOTE_SILENT: '1',
|
|
25
|
+
DEBUG: '',
|
|
26
|
+
NODE_ENV: 'production'
|
|
27
|
+
};
|
|
28
|
+
// Determine where to redirect stderr
|
|
29
|
+
let stderrTarget = 'ignore'; // Default: discard stderr output
|
|
30
|
+
if (this.config.debugLogFile) {
|
|
31
|
+
// Create debug log file synchronously
|
|
32
|
+
const debugLogPath = path.resolve(this.config.debugLogFile);
|
|
33
|
+
const debugLogDir = path.dirname(debugLogPath);
|
|
34
|
+
// Ensure debug log directory exists
|
|
35
|
+
if (!fs.existsSync(debugLogDir)) {
|
|
36
|
+
fs.mkdirSync(debugLogDir, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
// Open file synchronously for appending
|
|
39
|
+
this.debugLogFd = fs.openSync(debugLogPath, 'a');
|
|
40
|
+
// Write header synchronously
|
|
41
|
+
const header = `\n=== MCP Server Started: ${new Date().toISOString()} ===\n`;
|
|
42
|
+
const commandLine = `Command: ${this.config.command} ${(this.config.args || []).join(' ')}\n`;
|
|
43
|
+
fs.writeSync(this.debugLogFd, header);
|
|
44
|
+
fs.writeSync(this.debugLogFd, commandLine);
|
|
45
|
+
stderrTarget = this.debugLogFd;
|
|
46
|
+
}
|
|
47
|
+
this.transport = new StdioClientTransport({
|
|
48
|
+
command: this.config.command,
|
|
49
|
+
args: this.config.args || [],
|
|
50
|
+
env,
|
|
51
|
+
stderr: stderrTarget // Redirect stderr to log file or discard
|
|
52
|
+
});
|
|
53
|
+
return this.transport;
|
|
54
|
+
}
|
|
55
|
+
async disconnect() {
|
|
56
|
+
if (this.transport) {
|
|
57
|
+
await this.transport.close();
|
|
58
|
+
this.transport = undefined;
|
|
59
|
+
}
|
|
60
|
+
if (this.process) {
|
|
61
|
+
this.process.kill();
|
|
62
|
+
this.process = undefined;
|
|
63
|
+
}
|
|
64
|
+
if (this.debugLogFd !== undefined) {
|
|
65
|
+
const footer = `=== MCP Server Stopped: ${new Date().toISOString()} ===\n\n`;
|
|
66
|
+
fs.writeSync(this.debugLogFd, footer);
|
|
67
|
+
fs.closeSync(this.debugLogFd);
|
|
68
|
+
this.debugLogFd = undefined;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
getType() {
|
|
72
|
+
return 'stdio';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export class HttpTransport extends EventEmitter {
|
|
76
|
+
config;
|
|
77
|
+
client;
|
|
78
|
+
connected = false;
|
|
79
|
+
constructor(config) {
|
|
80
|
+
super();
|
|
81
|
+
this.config = config;
|
|
82
|
+
if (!config.url) {
|
|
83
|
+
throw new Error('URL is required for HTTP transport');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async connect() {
|
|
87
|
+
this.client = axios.create({
|
|
88
|
+
baseURL: this.config.url,
|
|
89
|
+
headers: {
|
|
90
|
+
'Content-Type': 'application/json',
|
|
91
|
+
...this.config.headers
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
// Test connection
|
|
95
|
+
try {
|
|
96
|
+
await this.client.get('/health');
|
|
97
|
+
this.connected = true;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
// If health endpoint doesn't exist, try a basic request
|
|
101
|
+
this.connected = true;
|
|
102
|
+
}
|
|
103
|
+
return new HttpClientTransport(this.client);
|
|
104
|
+
}
|
|
105
|
+
async disconnect() {
|
|
106
|
+
this.connected = false;
|
|
107
|
+
this.client = undefined;
|
|
108
|
+
}
|
|
109
|
+
getType() {
|
|
110
|
+
return 'http';
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export class SSETransport extends EventEmitter {
|
|
114
|
+
config;
|
|
115
|
+
connected = false;
|
|
116
|
+
constructor(config) {
|
|
117
|
+
super();
|
|
118
|
+
this.config = config;
|
|
119
|
+
if (!config.url) {
|
|
120
|
+
throw new Error('URL is required for SSE transport');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async connect() {
|
|
124
|
+
return new Promise((resolve, reject) => {
|
|
125
|
+
try {
|
|
126
|
+
// For Node.js environment, we'll use a simple HTTP-based approach
|
|
127
|
+
// In a real implementation, you'd use a proper SSE library like 'eventsource'
|
|
128
|
+
this.connected = true;
|
|
129
|
+
resolve(new SSEClientTransport(this.config.url));
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
reject(error);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
async disconnect() {
|
|
137
|
+
this.connected = false;
|
|
138
|
+
}
|
|
139
|
+
getType() {
|
|
140
|
+
return 'sse';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Custom HTTP Transport implementation
|
|
144
|
+
class HttpClientTransport extends EventEmitter {
|
|
145
|
+
client;
|
|
146
|
+
constructor(client) {
|
|
147
|
+
super();
|
|
148
|
+
this.client = client;
|
|
149
|
+
}
|
|
150
|
+
async start() {
|
|
151
|
+
// HTTP transport is connection-less, so we're always "started"
|
|
152
|
+
}
|
|
153
|
+
async close() {
|
|
154
|
+
// Nothing to close for HTTP transport
|
|
155
|
+
}
|
|
156
|
+
async send(message) {
|
|
157
|
+
try {
|
|
158
|
+
const response = await this.client.post('/rpc', message);
|
|
159
|
+
return response.data;
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
throw new Error(`HTTP transport error: ${error}`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// Custom SSE Transport implementation
|
|
167
|
+
class SSEClientTransport extends EventEmitter {
|
|
168
|
+
url;
|
|
169
|
+
constructor(url) {
|
|
170
|
+
super();
|
|
171
|
+
this.url = url;
|
|
172
|
+
}
|
|
173
|
+
async start() {
|
|
174
|
+
// SSE transport is event-driven, so we're always "started"
|
|
175
|
+
}
|
|
176
|
+
async close() {
|
|
177
|
+
// Nothing to close for basic SSE transport
|
|
178
|
+
}
|
|
179
|
+
async send(message) {
|
|
180
|
+
// For bidirectional communication over SSE, we typically use HTTP POST
|
|
181
|
+
// for sending messages and SSE for receiving
|
|
182
|
+
try {
|
|
183
|
+
const response = await axios.post(this.url.replace('/sse', '/rpc'), message, {
|
|
184
|
+
headers: { 'Content-Type': 'application/json' }
|
|
185
|
+
});
|
|
186
|
+
return response.data;
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
throw new Error(`SSE transport error: ${error}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
export class StreamableHttpTransport extends EventEmitter {
|
|
194
|
+
config;
|
|
195
|
+
connected = false;
|
|
196
|
+
constructor(config) {
|
|
197
|
+
super();
|
|
198
|
+
this.config = config;
|
|
199
|
+
if (!config.url) {
|
|
200
|
+
throw new Error('URL is required for streamable_http transport');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async connect() {
|
|
204
|
+
return new Promise((resolve, reject) => {
|
|
205
|
+
try {
|
|
206
|
+
this.connected = true;
|
|
207
|
+
resolve(new StreamableHttpClientTransport(this.config.url, this.config.headers));
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
reject(error);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
async disconnect() {
|
|
215
|
+
this.connected = false;
|
|
216
|
+
}
|
|
217
|
+
getType() {
|
|
218
|
+
return 'streamable_http';
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
// Custom Streamable HTTP Transport implementation for GitHub Copilot MCP
|
|
222
|
+
class StreamableHttpClientTransport extends EventEmitter {
|
|
223
|
+
url;
|
|
224
|
+
headers;
|
|
225
|
+
constructor(url, headers) {
|
|
226
|
+
super();
|
|
227
|
+
this.url = url;
|
|
228
|
+
this.headers = headers;
|
|
229
|
+
}
|
|
230
|
+
async start() {
|
|
231
|
+
// Streamable HTTP transport is connection-less, so we're always "started"
|
|
232
|
+
}
|
|
233
|
+
async close() {
|
|
234
|
+
// Nothing to close for streamable HTTP transport
|
|
235
|
+
}
|
|
236
|
+
async send(message) {
|
|
237
|
+
// For now, return a mock response to indicate the transport type is not compatible
|
|
238
|
+
// with the MCP protocol's request-response pattern
|
|
239
|
+
throw new Error('StreamableHttpTransport: SSE endpoints are not compatible with MCP request-response pattern. GitHub Copilot MCP may require a different integration approach.');
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
export function createTransport(config) {
|
|
243
|
+
switch (config.type) {
|
|
244
|
+
case 'stdio':
|
|
245
|
+
return new StdioTransport(config);
|
|
246
|
+
case 'http':
|
|
247
|
+
return new HttpTransport(config);
|
|
248
|
+
case 'sse':
|
|
249
|
+
return new SSETransport(config);
|
|
250
|
+
case 'streamable_http':
|
|
251
|
+
return new StreamableHttpTransport(config);
|
|
252
|
+
default:
|
|
253
|
+
throw new Error(`Unsupported transport type: ${config.type}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=transports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transports.js","sourceRoot":"","sources":["../../src/mcp/transports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAqB7B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AAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAED,OAAO;QACL,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF;AAED,yEAAyE;AACzE,MAAM,6BAA8B,SAAQ,YAAY;IAClC;IAAqB;IAAzC,YAAoB,GAAW,EAAU,OAAgC;QACvE,KAAK,EAAE,CAAC;QADU,QAAG,GAAH,GAAG,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAyB;IAEzE,CAAC;IAED,KAAK,CAAC,KAAK;QACT,0EAA0E;IAC5E,CAAC;IAED,KAAK,CAAC,KAAK;QACT,iDAAiD;IACnD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAY;QACrB,mFAAmF;QACnF,mDAAmD;QACnD,MAAM,IAAI,KAAK,CAAC,+JAA+J,CAAC,CAAC;IACnL,CAAC;CACF;AAED,MAAM,UAAU,eAAe,CAAC,MAAuB;IACrD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,OAAO;YACV,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QACpC,KAAK,MAAM;YACT,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QACnC,KAAK,KAAK;YACR,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;QAClC,KAAK,iBAAiB;YACpB,OAAO,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAC7C;YACE,MAAM,IAAI,KAAK,CAAC,+BAA+B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ToolResult } from "../types/index.js";
|
|
2
|
+
import { ToolDiscovery } from "./tool-discovery.js";
|
|
3
|
+
export declare class CharacterTool implements ToolDiscovery {
|
|
4
|
+
private agent;
|
|
5
|
+
setAgent(agent: any): void;
|
|
6
|
+
getHandledToolNames(): string[];
|
|
7
|
+
/**
|
|
8
|
+
* Set the persona display text in the status bar
|
|
9
|
+
*/
|
|
10
|
+
setPersona(persona: string, color?: string): Promise<ToolResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Set the mood display text in the status bar
|
|
13
|
+
*/
|
|
14
|
+
setMood(mood: string, color?: string): Promise<ToolResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Get the current persona display text and color
|
|
17
|
+
*/
|
|
18
|
+
getPersona(): Promise<ToolResult>;
|
|
19
|
+
/**
|
|
20
|
+
* Get the current mood display text and color
|
|
21
|
+
*/
|
|
22
|
+
getMood(): Promise<ToolResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Get available personas by calling the persona hook
|
|
25
|
+
*/
|
|
26
|
+
getAvailablePersonas(): Promise<ToolResult>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { executeOperationHook, applyHookCommands } from "../utils/hook-executor.js";
|
|
2
|
+
import { getSettingsManager } from "../utils/settings-manager.js";
|
|
3
|
+
export class CharacterTool {
|
|
4
|
+
agent; // Reference to the GrokAgent
|
|
5
|
+
setAgent(agent) {
|
|
6
|
+
this.agent = agent;
|
|
7
|
+
}
|
|
8
|
+
getHandledToolNames() {
|
|
9
|
+
return ["setPersona", "setMood", "getPersona", "getMood", "getAvailablePersonas"];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Set the persona display text in the status bar
|
|
13
|
+
*/
|
|
14
|
+
async setPersona(persona, color) {
|
|
15
|
+
try {
|
|
16
|
+
if (!this.agent) {
|
|
17
|
+
return {
|
|
18
|
+
success: false,
|
|
19
|
+
error: "Agent not available",
|
|
20
|
+
output: "Agent not available"
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// Set the persona (now async with hook support)
|
|
24
|
+
const result = await this.agent.setPersona(persona, color);
|
|
25
|
+
if (!result.success) {
|
|
26
|
+
return {
|
|
27
|
+
success: false,
|
|
28
|
+
error: result.error || "Failed to set persona",
|
|
29
|
+
output: result.error || "Failed to set persona"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
success: true,
|
|
34
|
+
output: `Persona set to: ${persona}${color ? ` (color: ${color})` : ''}`,
|
|
35
|
+
displayOutput: `Persona updated`
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return {
|
|
40
|
+
success: false,
|
|
41
|
+
error: error instanceof Error ? error.message : "Unknown error setting persona",
|
|
42
|
+
output: error instanceof Error ? error.message : "Unknown error setting persona"
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Set the mood display text in the status bar
|
|
48
|
+
*/
|
|
49
|
+
async setMood(mood, color) {
|
|
50
|
+
try {
|
|
51
|
+
if (!this.agent) {
|
|
52
|
+
return {
|
|
53
|
+
success: false,
|
|
54
|
+
error: "Agent not available",
|
|
55
|
+
output: "Agent not available"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
// Set the mood (now async with hook support)
|
|
59
|
+
const result = await this.agent.setMood(mood, color);
|
|
60
|
+
if (!result.success) {
|
|
61
|
+
return {
|
|
62
|
+
success: false,
|
|
63
|
+
error: result.error || "Failed to set mood",
|
|
64
|
+
output: result.error || "Failed to set mood"
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
success: true,
|
|
69
|
+
output: `Mood set to: ${mood}${color ? ` (color: ${color})` : ''}`,
|
|
70
|
+
displayOutput: `Mood updated`
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
return {
|
|
75
|
+
success: false,
|
|
76
|
+
error: error instanceof Error ? error.message : "Unknown error setting mood",
|
|
77
|
+
output: error instanceof Error ? error.message : "Unknown error setting mood"
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get the current persona display text and color
|
|
83
|
+
*/
|
|
84
|
+
async getPersona() {
|
|
85
|
+
try {
|
|
86
|
+
if (!this.agent) {
|
|
87
|
+
return {
|
|
88
|
+
success: false,
|
|
89
|
+
error: "Agent not available",
|
|
90
|
+
output: "Agent not available"
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const persona = this.agent.persona || "";
|
|
94
|
+
const color = this.agent.personaColor || "white";
|
|
95
|
+
return {
|
|
96
|
+
success: true,
|
|
97
|
+
output: `Current persona: "${persona}" (color: ${color})`,
|
|
98
|
+
displayOutput: `Persona: ${persona}`
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
error: error instanceof Error ? error.message : "Unknown error getting persona",
|
|
105
|
+
output: error instanceof Error ? error.message : "Unknown error getting persona"
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get the current mood display text and color
|
|
111
|
+
*/
|
|
112
|
+
async getMood() {
|
|
113
|
+
try {
|
|
114
|
+
if (!this.agent) {
|
|
115
|
+
return {
|
|
116
|
+
success: false,
|
|
117
|
+
error: "Agent not available",
|
|
118
|
+
output: "Agent not available"
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const mood = this.agent.mood || "";
|
|
122
|
+
const color = this.agent.moodColor || "white";
|
|
123
|
+
return {
|
|
124
|
+
success: true,
|
|
125
|
+
output: `Current mood: "${mood}" (color: ${color})`,
|
|
126
|
+
displayOutput: `Mood: ${mood}`
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
return {
|
|
131
|
+
success: false,
|
|
132
|
+
error: error instanceof Error ? error.message : "Unknown error getting mood",
|
|
133
|
+
output: error instanceof Error ? error.message : "Unknown error getting mood"
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get available personas by calling the persona hook
|
|
139
|
+
*/
|
|
140
|
+
async getAvailablePersonas() {
|
|
141
|
+
try {
|
|
142
|
+
const settings = getSettingsManager();
|
|
143
|
+
const hookPath = settings.getPersonaHook();
|
|
144
|
+
const hookMandatory = settings.isPersonaHookMandatory();
|
|
145
|
+
if (!hookPath) {
|
|
146
|
+
if (hookMandatory) {
|
|
147
|
+
return {
|
|
148
|
+
success: false,
|
|
149
|
+
error: "Persona hook is mandatory but not configured",
|
|
150
|
+
output: "Persona hook is mandatory but not configured"
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
success: false,
|
|
155
|
+
error: "No persona hook configured",
|
|
156
|
+
output: "No persona hook configured"
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const hookResult = await executeOperationHook(hookPath, "getAvailablePersonas", {}, 10000, hookMandatory, this.agent.getCurrentTokenCount(), this.agent.getMaxContextSize());
|
|
160
|
+
if (!hookResult.approved) {
|
|
161
|
+
return {
|
|
162
|
+
success: false,
|
|
163
|
+
error: hookResult.reason || "Failed to get available personas",
|
|
164
|
+
output: hookResult.reason || "Failed to get available personas"
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
// Apply hook commands (ENV, TOOL_RESULT, SYSTEM)
|
|
168
|
+
const results = hookResult.commands
|
|
169
|
+
? applyHookCommands(hookResult.commands)
|
|
170
|
+
: { env: {}, toolResult: "", system: "" };
|
|
171
|
+
// If no TOOL_RESULT was returned, the hook didn't provide personas
|
|
172
|
+
if (!results.toolResult) {
|
|
173
|
+
return {
|
|
174
|
+
success: false,
|
|
175
|
+
error: "Hook did not return available personas",
|
|
176
|
+
output: "Hook did not return available personas"
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
success: true,
|
|
181
|
+
output: results.toolResult,
|
|
182
|
+
displayOutput: "Available personas retrieved"
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
return {
|
|
187
|
+
success: false,
|
|
188
|
+
error: error instanceof Error ? error.message : "Unknown error getting available personas",
|
|
189
|
+
output: error instanceof Error ? error.message : "Unknown error getting available personas"
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=character-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"character-tool.js","sourceRoot":"","sources":["../../src/tools/character-tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,OAAO,aAAa;IAChB,KAAK,CAAM,CAAC,6BAA6B;IAEjD,QAAQ,CAAC,KAAU;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,mBAAmB;QACjB,OAAO,CAAC,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,sBAAsB,CAAC,CAAC;IACpF,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,OAAe,EAAE,KAAc;QAC9C,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;gBAChB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,qBAAqB;oBAC5B,MAAM,EAAE,qBAAqB;iBAC9B,CAAC;YACJ,CAAC;YAED,gDAAgD;YAChD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAE3D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,uBAAuB;oB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AC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,0CAA0C;aAC5F,CAAC;QACJ,CAAC;IACH,CAAC;CAEF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ToolResult } from "../types/index.js";
|
|
2
|
+
export declare class ClearCacheTool {
|
|
3
|
+
private agent;
|
|
4
|
+
private confirmationCode;
|
|
5
|
+
setAgent(agent: any): void;
|
|
6
|
+
/**
|
|
7
|
+
* Generate a random 6-letter confirmation code
|
|
8
|
+
*/
|
|
9
|
+
private generateConfirmationCode;
|
|
10
|
+
/**
|
|
11
|
+
* Clear the conversation cache/context
|
|
12
|
+
*/
|
|
13
|
+
clearCache(confirmationCode?: string): Promise<ToolResult>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export class ClearCacheTool {
|
|
2
|
+
agent; // Reference to the GrokAgent
|
|
3
|
+
confirmationCode = null;
|
|
4
|
+
setAgent(agent) {
|
|
5
|
+
this.agent = agent;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Generate a random 6-letter confirmation code
|
|
9
|
+
*/
|
|
10
|
+
generateConfirmationCode() {
|
|
11
|
+
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
12
|
+
let code = '';
|
|
13
|
+
for (let i = 0; i < 6; i++) {
|
|
14
|
+
code += letters.charAt(Math.floor(Math.random() * letters.length));
|
|
15
|
+
}
|
|
16
|
+
return code;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Clear the conversation cache/context
|
|
20
|
+
*/
|
|
21
|
+
async clearCache(confirmationCode) {
|
|
22
|
+
try {
|
|
23
|
+
// If no confirmation code stored yet, this is the first call
|
|
24
|
+
if (!this.confirmationCode) {
|
|
25
|
+
this.confirmationCode = this.generateConfirmationCode();
|
|
26
|
+
return {
|
|
27
|
+
success: true,
|
|
28
|
+
output: `Before clearing the cache, please ensure you have:
|
|
29
|
+
|
|
30
|
+
1. Updated any task statuses (mark todos as completed, in_progress, etc.)
|
|
31
|
+
2. Saved all notes and lessons learned to your notes files
|
|
32
|
+
3. Documented any important context for the next session
|
|
33
|
+
|
|
34
|
+
Once you have completed these steps, call clearCache again with the confirmation code: ${this.confirmationCode}
|
|
35
|
+
|
|
36
|
+
Example: clearCache("${this.confirmationCode}")`,
|
|
37
|
+
displayOutput: `Cache clear initiated. Confirmation code: ${this.confirmationCode}`
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Confirmation code was provided, validate it
|
|
41
|
+
if (!confirmationCode) {
|
|
42
|
+
return {
|
|
43
|
+
success: false,
|
|
44
|
+
error: `Confirmation code required. Please call clearCache("${this.confirmationCode}")`,
|
|
45
|
+
output: `Confirmation code required. Please call clearCache("${this.confirmationCode}")`
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (confirmationCode !== this.confirmationCode) {
|
|
49
|
+
return {
|
|
50
|
+
success: false,
|
|
51
|
+
error: `Invalid confirmation code. Expected: ${this.confirmationCode}`,
|
|
52
|
+
output: `Invalid confirmation code. Expected: ${this.confirmationCode}`
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// Valid confirmation code - proceed with cache clear
|
|
56
|
+
if (!this.agent) {
|
|
57
|
+
return {
|
|
58
|
+
success: false,
|
|
59
|
+
error: "Agent not available for cache clearing",
|
|
60
|
+
output: "Agent not available for cache clearing"
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Call the agent's existing clearCache method
|
|
64
|
+
await this.agent.clearCache();
|
|
65
|
+
// Reset confirmation code for next time
|
|
66
|
+
this.confirmationCode = null;
|
|
67
|
+
return {
|
|
68
|
+
success: true,
|
|
69
|
+
output: "Cache cleared successfully. Context has been reset and initial system messages reloaded.",
|
|
70
|
+
displayOutput: "Cache cleared successfully. Context reset."
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
return {
|
|
75
|
+
success: false,
|
|
76
|
+
error: error instanceof Error ? error.message : "Unknown error during cache clear",
|
|
77
|
+
output: error instanceof Error ? error.message : "Unknown error during cache clear"
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=clear-cache-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear-cache-tool.js","sourceRoot":"","sources":["../../src/tools/clear-cache-tool.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,cAAc;IACjB,KAAK,CAAM,CAAC,6BAA6B;IACzC,gBAAgB,GAAkB,IAAI,CAAC;IAE/C,QAAQ,CAAC,KAAU;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;OAEG;IACK,wBAAwB;QAC9B,MAAM,OAAO,GAAG,4BAA4B,CAAC;QAC7C,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3B,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,gBAAyB;QACxC,IAAI,CAAC;YACH,6DAA6D;YAC7D,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC3B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,wBAAwB,EAAE,CAAC;gBAExD,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,MAAM,EAAE;;;;;;yFAMuE,IAAI,CAAC,gBAAgB;;uBAEvF,IAAI,CAAC,gBAAgB,IAAI;oBACtC,aAAa,EAAE,8CAA8C,IAAI,CAAC,gBAAgB,EAAE;iBACrF,CAAC;YACJ,CAAC;Y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../types/index.js';
|
|
2
|
+
export interface ConfirmationRequest {
|
|
3
|
+
operation: string;
|
|
4
|
+
filename: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
showVSCodeOpen?: boolean;
|
|
7
|
+
autoAccept?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class ConfirmationTool {
|
|
10
|
+
private confirmationService;
|
|
11
|
+
constructor();
|
|
12
|
+
requestConfirmation(request: ConfirmationRequest): Promise<ToolResult>;
|
|
13
|
+
checkSessionAcceptance(): Promise<ToolResult>;
|
|
14
|
+
resetSession(): void;
|
|
15
|
+
isPending(): boolean;
|
|
16
|
+
}
|