lua-cli 2.3.2 โ 2.4.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/dist/api/products.api.service.js +1 -0
- package/dist/cli/command-definitions.d.ts +0 -8
- package/dist/cli/command-definitions.js +51 -18
- package/dist/commands/chat.d.ts +17 -0
- package/dist/commands/chat.js +236 -0
- package/dist/commands/chatClear.d.ts +15 -0
- package/dist/commands/chatClear.js +75 -0
- package/dist/commands/env.d.ts +19 -0
- package/dist/commands/env.js +434 -0
- package/dist/commands/index.d.ts +6 -0
- package/dist/commands/index.js +6 -0
- package/dist/commands/persona.d.ts +15 -0
- package/dist/commands/persona.js +503 -0
- package/dist/commands/production.d.ts +15 -0
- package/dist/commands/production.js +532 -0
- package/dist/commands/push.js +56 -0
- package/dist/commands/resources.d.ts +17 -0
- package/dist/commands/resources.js +361 -0
- package/dist/common/data.entry.instance.js +6 -2
- package/dist/config/compile.constants.d.ts +4 -3
- package/dist/config/compile.constants.js +3 -7
- package/dist/config/constants.d.ts +6 -0
- package/dist/config/constants.js +11 -0
- package/dist/index.d.ts +0 -9
- package/dist/index.js +30 -11
- package/dist/utils/bundling.js +61 -0
- package/dist/utils/prompt-handler.d.ts +12 -0
- package/dist/utils/prompt-handler.js +31 -0
- package/dist/utils/push-helpers.js +36 -31
- package/dist/utils/sandbox.js +2 -2
- package/dist/web/app.js +1 -1
- package/package.json +1 -1
- package/template/src/tools/BasketTool.ts +4 -1
- package/template/src/tools/ProductsTool.ts +7 -7
|
@@ -17,14 +17,6 @@ export declare function setupAuthCommands(program: Command): void;
|
|
|
17
17
|
/**
|
|
18
18
|
* Sets up skill management commands.
|
|
19
19
|
*
|
|
20
|
-
* Commands:
|
|
21
|
-
* - `lua init` - Initialize new project
|
|
22
|
-
* - `lua compile` - Compile skill
|
|
23
|
-
* - `lua test` - Test tools interactively
|
|
24
|
-
* - `lua push` - Push to server
|
|
25
|
-
* - `lua deploy` - Deploy to production
|
|
26
|
-
* - `lua dev` - Development mode with live reload
|
|
27
|
-
*
|
|
28
20
|
* @param program - Commander program instance
|
|
29
21
|
*/
|
|
30
22
|
export declare function setupSkillCommands(program: Command): void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Command Definitions
|
|
3
3
|
* Centralized command structure for the CLI
|
|
4
4
|
*/
|
|
5
|
-
import { configureCommand, initCommand, destroyCommand, apiKeyCommand, compileCommand, testCommand, pushCommand, deployCommand,
|
|
5
|
+
import { configureCommand, initCommand, destroyCommand, apiKeyCommand, compileCommand, testCommand, pushCommand, deployCommand, chatCommand, chatClearCommand, envCommand, personaCommand, productionCommand, resourcesCommand } from "../commands/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* Sets up authentication-related commands.
|
|
8
8
|
*
|
|
@@ -16,7 +16,13 @@ import { configureCommand, initCommand, destroyCommand, apiKeyCommand, compileCo
|
|
|
16
16
|
export function setupAuthCommands(program) {
|
|
17
17
|
const authCommand = program
|
|
18
18
|
.command("auth")
|
|
19
|
-
.description("Authentication management
|
|
19
|
+
.description("๐ Authentication management")
|
|
20
|
+
.addHelpText('after', `
|
|
21
|
+
Examples:
|
|
22
|
+
$ lua auth configure Set up your API key for the first time
|
|
23
|
+
$ lua auth key View your current API key
|
|
24
|
+
$ lua auth logout Remove stored credentials
|
|
25
|
+
`);
|
|
20
26
|
authCommand
|
|
21
27
|
.command("configure")
|
|
22
28
|
.description("Set up your API key")
|
|
@@ -33,39 +39,66 @@ export function setupAuthCommands(program) {
|
|
|
33
39
|
/**
|
|
34
40
|
* Sets up skill management commands.
|
|
35
41
|
*
|
|
36
|
-
* Commands:
|
|
37
|
-
* - `lua init` - Initialize new project
|
|
38
|
-
* - `lua compile` - Compile skill
|
|
39
|
-
* - `lua test` - Test tools interactively
|
|
40
|
-
* - `lua push` - Push to server
|
|
41
|
-
* - `lua deploy` - Deploy to production
|
|
42
|
-
* - `lua dev` - Development mode with live reload
|
|
43
|
-
*
|
|
44
42
|
* @param program - Commander program instance
|
|
45
43
|
*/
|
|
46
44
|
export function setupSkillCommands(program) {
|
|
45
|
+
// Project Setup
|
|
47
46
|
program
|
|
48
47
|
.command("init")
|
|
49
|
-
.description("Initialize a new Lua skill project")
|
|
48
|
+
.description("๐ Initialize a new Lua skill project")
|
|
50
49
|
.action(initCommand);
|
|
50
|
+
// Development Commands
|
|
51
51
|
program
|
|
52
52
|
.command("compile")
|
|
53
|
-
.description("Compile
|
|
53
|
+
.description("๐ฆ Compile skill to deployable format")
|
|
54
54
|
.action(compileCommand);
|
|
55
55
|
program
|
|
56
56
|
.command("test")
|
|
57
|
-
.description("Test
|
|
57
|
+
.description("๐งช Test skill tools interactively")
|
|
58
58
|
.action(testCommand);
|
|
59
|
+
// Deployment Commands
|
|
59
60
|
program
|
|
60
61
|
.command("push")
|
|
61
|
-
.description("Push
|
|
62
|
+
.description("โ๏ธ Push skill version to server")
|
|
62
63
|
.action(pushCommand);
|
|
63
64
|
program
|
|
64
65
|
.command("deploy")
|
|
65
|
-
.description("Deploy
|
|
66
|
+
.description("๐ Deploy version to production")
|
|
66
67
|
.action(deployCommand);
|
|
68
|
+
// Temporarily disabled - will be released later
|
|
69
|
+
// program
|
|
70
|
+
// .command("dev")
|
|
71
|
+
// .description("๐ง Development mode with live reload")
|
|
72
|
+
// .action(devCommand);
|
|
73
|
+
// Chat Commands
|
|
74
|
+
const chatCmd = program
|
|
75
|
+
.command("chat")
|
|
76
|
+
.description("๐ฌ Interactive chat with your agent")
|
|
77
|
+
.addHelpText('after', `
|
|
78
|
+
Examples:
|
|
79
|
+
$ lua chat Start interactive chat session
|
|
80
|
+
$ lua chat clear Clear all conversation history
|
|
81
|
+
`)
|
|
82
|
+
.action(chatCommand);
|
|
83
|
+
chatCmd
|
|
84
|
+
.command("clear")
|
|
85
|
+
.description("Clear conversation history")
|
|
86
|
+
.action(chatClearCommand);
|
|
87
|
+
// Configuration Commands
|
|
88
|
+
program
|
|
89
|
+
.command("env")
|
|
90
|
+
.description("โ๏ธ Manage environment variables")
|
|
91
|
+
.action(envCommand);
|
|
92
|
+
program
|
|
93
|
+
.command("persona")
|
|
94
|
+
.description("๐ค Manage agent persona")
|
|
95
|
+
.action(personaCommand);
|
|
96
|
+
program
|
|
97
|
+
.command("production")
|
|
98
|
+
.description("๐ View and manage production environment")
|
|
99
|
+
.action(productionCommand);
|
|
67
100
|
program
|
|
68
|
-
.command("
|
|
69
|
-
.description("
|
|
70
|
-
.action(
|
|
101
|
+
.command("resources")
|
|
102
|
+
.description("๐ Manage agent resources and knowledge base")
|
|
103
|
+
.action(resourcesCommand);
|
|
71
104
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Command
|
|
3
|
+
* Interactive CLI chat interface with sandbox or production environment
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Main chat command - starts interactive chat session
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Environment selection (sandbox or production)
|
|
10
|
+
* - Interactive chat loop
|
|
11
|
+
* - Skill and persona overrides for sandbox
|
|
12
|
+
* - Real-time conversation
|
|
13
|
+
* - Exit with Ctrl+C
|
|
14
|
+
*
|
|
15
|
+
* @returns Promise that resolves when chat session ends
|
|
16
|
+
*/
|
|
17
|
+
export declare function chatCommand(): Promise<void>;
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Command
|
|
3
|
+
* Interactive CLI chat interface with sandbox or production environment
|
|
4
|
+
*/
|
|
5
|
+
import * as readline from 'readline';
|
|
6
|
+
import inquirer from 'inquirer';
|
|
7
|
+
import { loadApiKey, checkApiKey } from '../services/auth.js';
|
|
8
|
+
import { readSkillConfig } from '../utils/files.js';
|
|
9
|
+
import { withErrorHandling, writeProgress, writeSuccess } from '../utils/cli.js';
|
|
10
|
+
import { compileCommand } from './compile.js';
|
|
11
|
+
import { pushSkillsToSandbox } from '../utils/dev-api.js';
|
|
12
|
+
import { getAllSandboxSkillIds } from '../utils/sandbox-storage.js';
|
|
13
|
+
import ChatApi from '../api/chat.api.service.js';
|
|
14
|
+
import { BASE_URLS } from '../config/constants.js';
|
|
15
|
+
import { readDeployJson, validateConfig, validateDeployData, validateAgentConfig, } from '../utils/dev-helpers.js';
|
|
16
|
+
/**
|
|
17
|
+
* Main chat command - starts interactive chat session
|
|
18
|
+
*
|
|
19
|
+
* Features:
|
|
20
|
+
* - Environment selection (sandbox or production)
|
|
21
|
+
* - Interactive chat loop
|
|
22
|
+
* - Skill and persona overrides for sandbox
|
|
23
|
+
* - Real-time conversation
|
|
24
|
+
* - Exit with Ctrl+C
|
|
25
|
+
*
|
|
26
|
+
* @returns Promise that resolves when chat session ends
|
|
27
|
+
*/
|
|
28
|
+
export async function chatCommand() {
|
|
29
|
+
return withErrorHandling(async () => {
|
|
30
|
+
// Step 1: Authenticate
|
|
31
|
+
const apiKey = await loadApiKey();
|
|
32
|
+
if (!apiKey) {
|
|
33
|
+
console.error("โ No API key found. Please run 'lua auth configure' to set up your API key.");
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
const userData = await checkApiKey(apiKey);
|
|
37
|
+
writeProgress("โ
Authenticated");
|
|
38
|
+
// Step 2: Load configuration
|
|
39
|
+
const config = readSkillConfig();
|
|
40
|
+
validateConfig(config);
|
|
41
|
+
validateAgentConfig(config);
|
|
42
|
+
const agentId = config.agent.agentId;
|
|
43
|
+
// Step 3: Select environment
|
|
44
|
+
const { environment } = await inquirer.prompt([
|
|
45
|
+
{
|
|
46
|
+
type: 'list',
|
|
47
|
+
name: 'environment',
|
|
48
|
+
message: 'Select environment:',
|
|
49
|
+
choices: [
|
|
50
|
+
{ name: '๐ง Sandbox (with skill overrides)', value: 'sandbox' },
|
|
51
|
+
{ name: '๐ Production', value: 'production' }
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
]);
|
|
55
|
+
let chatEnv = {
|
|
56
|
+
type: environment,
|
|
57
|
+
agentId,
|
|
58
|
+
apiKey,
|
|
59
|
+
};
|
|
60
|
+
// Step 4: Setup sandbox if selected
|
|
61
|
+
if (environment === 'sandbox') {
|
|
62
|
+
await setupSandboxEnvironment(chatEnv, config);
|
|
63
|
+
}
|
|
64
|
+
// Step 5: Start interactive chat
|
|
65
|
+
await startChatLoop(chatEnv);
|
|
66
|
+
}, "chat");
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Sets up the sandbox environment by compiling and pushing skills
|
|
70
|
+
*/
|
|
71
|
+
async function setupSandboxEnvironment(chatEnv, config) {
|
|
72
|
+
writeProgress("๐ Setting up sandbox environment...");
|
|
73
|
+
// Compile the skill
|
|
74
|
+
writeProgress("๐ Compiling skill...");
|
|
75
|
+
await compileCommand();
|
|
76
|
+
// Read deploy data
|
|
77
|
+
const deployData = readDeployJson();
|
|
78
|
+
validateDeployData(deployData);
|
|
79
|
+
// Push skills to sandbox
|
|
80
|
+
writeProgress("๐ Pushing skills to sandbox...");
|
|
81
|
+
const sandboxIds = await pushSkillsToSandbox(chatEnv.apiKey, chatEnv.agentId, deployData, true);
|
|
82
|
+
if (Object.keys(sandboxIds).length === 0) {
|
|
83
|
+
console.error("โ Failed to push any skills to sandbox. Cannot start chat.");
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
writeSuccess(`โ
Pushed ${Object.keys(sandboxIds).length} skills to sandbox`);
|
|
87
|
+
// Store deploy data for skill overrides
|
|
88
|
+
chatEnv.deployData = deployData;
|
|
89
|
+
// Check for persona in config
|
|
90
|
+
if (config.agent?.persona) {
|
|
91
|
+
chatEnv.persona = config.agent.persona;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Starts the interactive chat loop
|
|
96
|
+
*/
|
|
97
|
+
async function startChatLoop(chatEnv) {
|
|
98
|
+
console.log("\n" + "=".repeat(60));
|
|
99
|
+
console.log("๐ Lua Chat Interface");
|
|
100
|
+
console.log(`Environment: ${chatEnv.type === 'sandbox' ? '๐ง Sandbox' : '๐ Production'}`);
|
|
101
|
+
console.log("Press Ctrl+C to exit");
|
|
102
|
+
console.log("=".repeat(60) + "\n");
|
|
103
|
+
// Welcome message
|
|
104
|
+
console.log("๐ Assistant: Hi there! How can I help you today?\n");
|
|
105
|
+
// Create readline interface
|
|
106
|
+
const rl = readline.createInterface({
|
|
107
|
+
input: process.stdin,
|
|
108
|
+
output: process.stdout,
|
|
109
|
+
prompt: '๐ฌ You: '
|
|
110
|
+
});
|
|
111
|
+
// Handle Ctrl+C gracefully
|
|
112
|
+
rl.on('SIGINT', () => {
|
|
113
|
+
console.log("\n\n๐ Goodbye!");
|
|
114
|
+
rl.close();
|
|
115
|
+
process.exit(0);
|
|
116
|
+
});
|
|
117
|
+
// Show prompt
|
|
118
|
+
rl.prompt();
|
|
119
|
+
// Handle user input
|
|
120
|
+
rl.on('line', async (input) => {
|
|
121
|
+
const message = input.trim();
|
|
122
|
+
if (!message) {
|
|
123
|
+
rl.prompt();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
// Show typing indicator with animated dots
|
|
128
|
+
const typingInterval = startTypingIndicator();
|
|
129
|
+
let response = null;
|
|
130
|
+
if (chatEnv.type === 'sandbox') {
|
|
131
|
+
// Send to sandbox with skill overrides
|
|
132
|
+
response = await sendSandboxMessage(chatEnv, message);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
// Send to production
|
|
136
|
+
response = await sendProductionMessage(chatEnv, message);
|
|
137
|
+
}
|
|
138
|
+
// Stop typing indicator
|
|
139
|
+
stopTypingIndicator(typingInterval);
|
|
140
|
+
if (response) {
|
|
141
|
+
console.log(`๐ Assistant: ${response}\n`);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
console.log("๐ Assistant: โ Failed to get response. Please try again.\n");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
console.error(`\nโ Error: ${error instanceof Error ? error.message : 'Unknown error'}\n`);
|
|
149
|
+
}
|
|
150
|
+
rl.prompt();
|
|
151
|
+
});
|
|
152
|
+
rl.on('close', () => {
|
|
153
|
+
console.log("\n๐ Goodbye!");
|
|
154
|
+
process.exit(0);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Starts a typing indicator animation with dots
|
|
159
|
+
* @returns The interval ID to stop the animation later
|
|
160
|
+
*/
|
|
161
|
+
function startTypingIndicator() {
|
|
162
|
+
const frames = [' ', '. ', '.. ', '...'];
|
|
163
|
+
let frameIndex = 0;
|
|
164
|
+
// Initial frame
|
|
165
|
+
process.stdout.write(`\r๐ Assistant: ${frames[frameIndex]}`);
|
|
166
|
+
const interval = setInterval(() => {
|
|
167
|
+
frameIndex = (frameIndex + 1) % frames.length;
|
|
168
|
+
process.stdout.write(`\r๐ Assistant: ${frames[frameIndex]}`);
|
|
169
|
+
}, 500);
|
|
170
|
+
return interval;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Stops the typing indicator animation and clears the line
|
|
174
|
+
* @param interval The interval ID from startTypingIndicator
|
|
175
|
+
*/
|
|
176
|
+
function stopTypingIndicator(interval) {
|
|
177
|
+
clearInterval(interval);
|
|
178
|
+
// Clear the typing indicator line
|
|
179
|
+
process.stdout.write('\r\x1b[K');
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Sends a message to the sandbox environment with skill overrides
|
|
183
|
+
*/
|
|
184
|
+
async function sendSandboxMessage(chatEnv, message) {
|
|
185
|
+
if (!chatEnv.deployData) {
|
|
186
|
+
return "โ Sandbox environment not properly initialized.";
|
|
187
|
+
}
|
|
188
|
+
// Get all sandbox skill IDs for skill override
|
|
189
|
+
const allSkillOverrides = await getAllSandboxSkillIds(chatEnv.deployData);
|
|
190
|
+
if (allSkillOverrides.length === 0) {
|
|
191
|
+
return "โ No sandbox skills found. Please try running the command again.";
|
|
192
|
+
}
|
|
193
|
+
const chatRequest = {
|
|
194
|
+
messages: [
|
|
195
|
+
{
|
|
196
|
+
type: "text",
|
|
197
|
+
text: message
|
|
198
|
+
}
|
|
199
|
+
],
|
|
200
|
+
navigate: true,
|
|
201
|
+
skillOverride: allSkillOverrides
|
|
202
|
+
};
|
|
203
|
+
// Add persona override if available
|
|
204
|
+
if (chatEnv.persona) {
|
|
205
|
+
chatRequest.personaOverride = chatEnv.persona;
|
|
206
|
+
}
|
|
207
|
+
const chatApi = new ChatApi(BASE_URLS.CHAT, chatEnv.apiKey);
|
|
208
|
+
const response = await chatApi.sendMessage(chatEnv.agentId, chatRequest);
|
|
209
|
+
if (!response.success) {
|
|
210
|
+
console.error(`โ Chat API error: ${response.error?.message || 'Unknown error'}`);
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
return response.data?.text || null;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Sends a message to the production environment
|
|
217
|
+
*/
|
|
218
|
+
async function sendProductionMessage(chatEnv, message) {
|
|
219
|
+
const chatRequest = {
|
|
220
|
+
messages: [
|
|
221
|
+
{
|
|
222
|
+
type: "text",
|
|
223
|
+
text: message
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
navigate: true,
|
|
227
|
+
skillOverride: []
|
|
228
|
+
};
|
|
229
|
+
const chatApi = new ChatApi(BASE_URLS.CHAT, chatEnv.apiKey);
|
|
230
|
+
const response = await chatApi.sendMessage(chatEnv.agentId, chatRequest);
|
|
231
|
+
if (!response.success) {
|
|
232
|
+
console.error(`โ Chat API error: ${response.error?.message || 'Unknown error'}`);
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
return response.data?.text || null;
|
|
236
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Clear Command
|
|
3
|
+
* Clears conversation history for the agent
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Chat clear command - clears conversation history
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Warning message about data loss
|
|
10
|
+
* - Confirmation prompt
|
|
11
|
+
* - Calls DELETE endpoint to clear history
|
|
12
|
+
*
|
|
13
|
+
* @returns Promise that resolves when history is cleared
|
|
14
|
+
*/
|
|
15
|
+
export declare function chatClearCommand(): Promise<void>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Clear Command
|
|
3
|
+
* Clears conversation history for the agent
|
|
4
|
+
*/
|
|
5
|
+
import { loadApiKey, checkApiKey } from '../services/auth.js';
|
|
6
|
+
import { readSkillConfig } from '../utils/files.js';
|
|
7
|
+
import { withErrorHandling, writeProgress, writeSuccess } from '../utils/cli.js';
|
|
8
|
+
import { BASE_URLS } from '../config/constants.js';
|
|
9
|
+
import { safePrompt } from '../utils/prompt-handler.js';
|
|
10
|
+
import { validateConfig, validateAgentConfig, } from '../utils/dev-helpers.js';
|
|
11
|
+
/**
|
|
12
|
+
* Chat clear command - clears conversation history
|
|
13
|
+
*
|
|
14
|
+
* Features:
|
|
15
|
+
* - Warning message about data loss
|
|
16
|
+
* - Confirmation prompt
|
|
17
|
+
* - Calls DELETE endpoint to clear history
|
|
18
|
+
*
|
|
19
|
+
* @returns Promise that resolves when history is cleared
|
|
20
|
+
*/
|
|
21
|
+
export async function chatClearCommand() {
|
|
22
|
+
return withErrorHandling(async () => {
|
|
23
|
+
// Step 1: Load configuration
|
|
24
|
+
const config = readSkillConfig();
|
|
25
|
+
validateConfig(config);
|
|
26
|
+
validateAgentConfig(config);
|
|
27
|
+
const agentId = config.agent.agentId;
|
|
28
|
+
// Step 2: Authenticate
|
|
29
|
+
const apiKey = await loadApiKey();
|
|
30
|
+
if (!apiKey) {
|
|
31
|
+
console.error("โ No API key found. Please run 'lua auth configure' to set up your API key.");
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
await checkApiKey(apiKey);
|
|
35
|
+
writeProgress("โ
Authenticated");
|
|
36
|
+
// Step 3: Show warning and confirm
|
|
37
|
+
console.log("\nโ ๏ธ WARNING: This will clear ALL conversation history!");
|
|
38
|
+
console.log("โ ๏ธ This action cannot be undone.\n");
|
|
39
|
+
const confirmAnswer = await safePrompt([
|
|
40
|
+
{
|
|
41
|
+
type: 'confirm',
|
|
42
|
+
name: 'confirm',
|
|
43
|
+
message: 'Are you sure you want to clear the conversation history?',
|
|
44
|
+
default: false
|
|
45
|
+
}
|
|
46
|
+
]);
|
|
47
|
+
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
48
|
+
console.log("\nโ Operation cancelled. History not cleared.\n");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// Step 4: Clear history via API
|
|
52
|
+
writeProgress("๐ Clearing conversation history...");
|
|
53
|
+
try {
|
|
54
|
+
const response = await fetch(`${BASE_URLS.API}/chat/history/${agentId}`, {
|
|
55
|
+
method: 'DELETE',
|
|
56
|
+
headers: {
|
|
57
|
+
'accept': '*/*',
|
|
58
|
+
'Authorization': `Bearer ${apiKey}`
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
if (!response.ok) {
|
|
62
|
+
const errorText = await response.text();
|
|
63
|
+
throw new Error(`HTTP error! status: ${response.status} - ${errorText}`);
|
|
64
|
+
}
|
|
65
|
+
writeSuccess("โ
Conversation history cleared successfully");
|
|
66
|
+
console.log("๐ก The chat history has been completely removed.\n");
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error('โ Error clearing conversation history:', error);
|
|
70
|
+
if (error instanceof Error) {
|
|
71
|
+
console.error(` ${error.message}\n`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}, "chat clear");
|
|
75
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Variables Command
|
|
3
|
+
* Manages environment variables for sandbox and production environments
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Main env command - manages environment variables
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Environment selection (sandbox or production)
|
|
10
|
+
* - List all environment variables
|
|
11
|
+
* - Add new variables
|
|
12
|
+
* - Update existing variables
|
|
13
|
+
* - Delete variables
|
|
14
|
+
* - Sandbox: manages .env file
|
|
15
|
+
* - Production: uses API endpoints
|
|
16
|
+
*
|
|
17
|
+
* @returns Promise that resolves when command completes
|
|
18
|
+
*/
|
|
19
|
+
export declare function envCommand(): Promise<void>;
|