centaurus-cli 2.5.2 → 2.5.3
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/AUTH_FLOW.md +138 -0
- package/CONFIG_GUIDE.md +249 -0
- package/dist/config/models.d.ts +1 -1
- package/dist/config/models.d.ts.map +1 -1
- package/dist/config/models.js +2 -0
- package/dist/config/models.js.map +1 -1
- package/dist/ui/components/App.d.ts.map +1 -1
- package/dist/ui/components/App.js +104 -62
- package/dist/ui/components/App.js.map +1 -1
- package/dist/ui/components/FontRecommendation.d.ts +1 -0
- package/dist/ui/components/FontRecommendation.d.ts.map +1 -0
- package/dist/ui/components/FontRecommendation.js +1 -0
- package/dist/ui/components/FontRecommendation.js.map +1 -0
- package/dist/ui/components/InputBox.d.ts.map +1 -1
- package/dist/ui/components/InputBox.js +3 -2
- package/dist/ui/components/InputBox.js.map +1 -1
- package/dist/ui/components/MarkdownRenderer.d.ts.map +1 -1
- package/dist/ui/components/MarkdownRenderer.js +34 -9
- package/dist/ui/components/MarkdownRenderer.js.map +1 -1
- package/dist/ui/components/MessageDisplay.js +2 -2
- package/dist/ui/components/StreamingMessageDisplay.d.ts.map +1 -1
- package/dist/ui/components/StreamingMessageDisplay.js +3 -3
- package/dist/ui/components/StreamingMessageDisplay.js.map +1 -1
- package/dist/ui/components/ThinkingDisplay.d.ts +13 -0
- package/dist/ui/components/ThinkingDisplay.d.ts.map +1 -0
- package/dist/ui/components/ThinkingDisplay.js +41 -0
- package/dist/ui/components/ThinkingDisplay.js.map +1 -0
- package/dist/utils/version-checker.d.ts.map +1 -1
- package/dist/utils/version-checker.js +3 -31
- package/dist/utils/version-checker.js.map +1 -1
- package/package.json +5 -5
- package/dist/ai/provider-factory.d.ts +0 -6
- package/dist/ai/provider-factory.d.ts.map +0 -1
- package/dist/ai/provider-factory.js +0 -27
- package/dist/ai/provider-factory.js.map +0 -1
- package/dist/ai/providers/base.d.ts +0 -25
- package/dist/ai/providers/base.d.ts.map +0 -1
- package/dist/ai/providers/base.js +0 -9
- package/dist/ai/providers/base.js.map +0 -1
- package/dist/ai/providers/gemini.d.ts +0 -34
- package/dist/ai/providers/gemini.d.ts.map +0 -1
- package/dist/ai/providers/gemini.js +0 -146
- package/dist/ai/providers/gemini.js.map +0 -1
- package/dist/commands/view-duplication-logs.d.ts +0 -5
- package/dist/commands/view-duplication-logs.d.ts.map +0 -1
- package/dist/commands/view-duplication-logs.js +0 -14
- package/dist/commands/view-duplication-logs.js.map +0 -1
- package/dist/context/__tests__/command-detector.test.d.ts +0 -14
- package/dist/context/__tests__/command-detector.test.d.ts.map +0 -1
- package/dist/context/__tests__/command-detector.test.js +0 -318
- package/dist/context/__tests__/command-detector.test.js.map +0 -1
- package/dist/context/__tests__/context-manager.test.d.ts +0 -16
- package/dist/context/__tests__/context-manager.test.d.ts.map +0 -1
- package/dist/context/__tests__/context-manager.test.js +0 -375
- package/dist/context/__tests__/context-manager.test.js.map +0 -1
- package/dist/context/__tests__/error-handling.test.d.ts +0 -15
- package/dist/context/__tests__/error-handling.test.d.ts.map +0 -1
- package/dist/context/__tests__/error-handling.test.js +0 -447
- package/dist/context/__tests__/error-handling.test.js.map +0 -1
- package/dist/context/handlers/__tests__/docker-handler.test.d.ts +0 -13
- package/dist/context/handlers/__tests__/docker-handler.test.d.ts.map +0 -1
- package/dist/context/handlers/__tests__/docker-handler.test.js +0 -285
- package/dist/context/handlers/__tests__/docker-handler.test.js.map +0 -1
- package/dist/context/handlers/__tests__/ssh-handler.test.d.ts +0 -13
- package/dist/context/handlers/__tests__/ssh-handler.test.d.ts.map +0 -1
- package/dist/context/handlers/__tests__/ssh-handler.test.js +0 -251
- package/dist/context/handlers/__tests__/ssh-handler.test.js.map +0 -1
- package/dist/context/handlers/__tests__/wsl-handler.test.d.ts +0 -7
- package/dist/context/handlers/__tests__/wsl-handler.test.d.ts.map +0 -1
- package/dist/context/handlers/__tests__/wsl-handler.test.js +0 -331
- package/dist/context/handlers/__tests__/wsl-handler.test.js.map +0 -1
- package/dist/index-custom.d.ts +0 -3
- package/dist/index-custom.d.ts.map +0 -1
- package/dist/index-custom.js +0 -65
- package/dist/index-custom.js.map +0 -1
- package/dist/prompts/system-prompt.d.ts +0 -47
- package/dist/prompts/system-prompt.d.ts.map +0 -1
- package/dist/prompts/system-prompt.js +0 -377
- package/dist/prompts/system-prompt.js.map +0 -1
- package/dist/providers/GoogleProvider.d.ts +0 -26
- package/dist/providers/GoogleProvider.d.ts.map +0 -1
- package/dist/providers/GoogleProvider.js +0 -313
- package/dist/providers/GoogleProvider.js.map +0 -1
- package/dist/providers/Provider.d.ts +0 -114
- package/dist/providers/Provider.d.ts.map +0 -1
- package/dist/providers/Provider.js +0 -44
- package/dist/providers/Provider.js.map +0 -1
- package/dist/services/__tests__/ai-context-injector.test.d.ts +0 -15
- package/dist/services/__tests__/ai-context-injector.test.d.ts.map +0 -1
- package/dist/services/__tests__/ai-context-injector.test.js +0 -326
- package/dist/services/__tests__/ai-context-injector.test.js.map +0 -1
- package/dist/src/context/types.js +0 -27
- package/dist/src/services/ai-context-injector.js +0 -96
- package/dist/src/services/ai-service-client.js +0 -270
- package/dist/src/services/api-client.js +0 -349
- package/dist/src/tools/types.js +0 -1
- package/dist/src/types/index.js +0 -1
- package/dist/test/context/types.js +0 -27
- package/dist/test/services/__tests__/ai-context-injector.test.js +0 -325
- package/dist/test/services/ai-context-injector.js +0 -96
- package/dist/test/services/ai-service-client.js +0 -270
- package/dist/test/services/api-client.js +0 -349
- package/dist/test/tools/types.js +0 -1
- package/dist/test/types/index.js +0 -1
- package/dist/test-ai-context-injector.js +0 -97
- package/dist/tests/automated-verification.d.ts +0 -27
- package/dist/tests/automated-verification.d.ts.map +0 -1
- package/dist/tests/automated-verification.js +0 -359
- package/dist/tests/automated-verification.js.map +0 -1
- package/dist/tests/integration-tests.d.ts +0 -50
- package/dist/tests/integration-tests.d.ts.map +0 -1
- package/dist/tests/integration-tests.js +0 -648
- package/dist/tests/integration-tests.js.map +0 -1
- package/dist/tools/file-ops-test.d.ts +0 -6
- package/dist/tools/file-ops-test.d.ts.map +0 -1
- package/dist/tools/file-ops-test.js +0 -197
- package/dist/tools/file-ops-test.js.map +0 -1
- package/dist/ui/DisplayHistory.d.ts +0 -53
- package/dist/ui/DisplayHistory.d.ts.map +0 -1
- package/dist/ui/DisplayHistory.js +0 -82
- package/dist/ui/DisplayHistory.js.map +0 -1
- package/dist/ui/clack-ui.d.ts +0 -83
- package/dist/ui/clack-ui.d.ts.map +0 -1
- package/dist/ui/clack-ui.js +0 -304
- package/dist/ui/clack-ui.js.map +0 -1
- package/dist/ui/components/DisplayItemRenderer.d.ts +0 -18
- package/dist/ui/components/DisplayItemRenderer.d.ts.map +0 -1
- package/dist/ui/components/DisplayItemRenderer.js +0 -53
- package/dist/ui/components/DisplayItemRenderer.js.map +0 -1
- package/dist/ui/components/DynamicMessage.d.ts +0 -13
- package/dist/ui/components/DynamicMessage.d.ts.map +0 -1
- package/dist/ui/components/DynamicMessage.js +0 -27
- package/dist/ui/components/DynamicMessage.js.map +0 -1
- package/dist/ui/components/FileViewerScreen.d.ts +0 -14
- package/dist/ui/components/FileViewerScreen.d.ts.map +0 -1
- package/dist/ui/components/FileViewerScreen.js +0 -74
- package/dist/ui/components/FileViewerScreen.js.map +0 -1
- package/dist/ui/components/ScrollableContent.d.ts +0 -7
- package/dist/ui/components/ScrollableContent.d.ts.map +0 -1
- package/dist/ui/components/ScrollableContent.js +0 -6
- package/dist/ui/components/ScrollableContent.js.map +0 -1
- package/dist/ui/components/ScrollableMessageList.d.ts +0 -10
- package/dist/ui/components/ScrollableMessageList.d.ts.map +0 -1
- package/dist/ui/components/ScrollableMessageList.js +0 -133
- package/dist/ui/components/ScrollableMessageList.js.map +0 -1
- package/dist/ui/components/ScrollableScreen.d.ts +0 -9
- package/dist/ui/components/ScrollableScreen.d.ts.map +0 -1
- package/dist/ui/components/ScrollableScreen.js +0 -22
- package/dist/ui/components/ScrollableScreen.js.map +0 -1
- package/dist/ui/components/StaticMessageHistory.d.ts +0 -14
- package/dist/ui/components/StaticMessageHistory.d.ts.map +0 -1
- package/dist/ui/components/StaticMessageHistory.js +0 -19
- package/dist/ui/components/StaticMessageHistory.js.map +0 -1
- package/dist/ui/components/code-block.d.ts +0 -10
- package/dist/ui/components/code-block.d.ts.map +0 -1
- package/dist/ui/components/code-block.js +0 -74
- package/dist/ui/components/code-block.js.map +0 -1
- package/dist/ui/components/confirm-prompt.d.ts +0 -12
- package/dist/ui/components/confirm-prompt.d.ts.map +0 -1
- package/dist/ui/components/confirm-prompt.js +0 -104
- package/dist/ui/components/confirm-prompt.js.map +0 -1
- package/dist/ui/components/diff-viewer.d.ts +0 -9
- package/dist/ui/components/diff-viewer.d.ts.map +0 -1
- package/dist/ui/components/diff-viewer.js +0 -57
- package/dist/ui/components/diff-viewer.js.map +0 -1
- package/dist/ui/components/input-box.d.ts +0 -18
- package/dist/ui/components/input-box.d.ts.map +0 -1
- package/dist/ui/components/input-box.js +0 -157
- package/dist/ui/components/input-box.js.map +0 -1
- package/dist/ui/components/keyboard-help.d.ts +0 -7
- package/dist/ui/components/keyboard-help.d.ts.map +0 -1
- package/dist/ui/components/keyboard-help.js +0 -43
- package/dist/ui/components/keyboard-help.js.map +0 -1
- package/dist/ui/components/loading-indicator.d.ts +0 -3
- package/dist/ui/components/loading-indicator.d.ts.map +0 -1
- package/dist/ui/components/loading-indicator.js +0 -42
- package/dist/ui/components/loading-indicator.js.map +0 -1
- package/dist/ui/components/message-display.d.ts +0 -7
- package/dist/ui/components/message-display.d.ts.map +0 -1
- package/dist/ui/components/message-display.js +0 -104
- package/dist/ui/components/message-display.js.map +0 -1
- package/dist/ui/components/misc.d.ts +0 -28
- package/dist/ui/components/misc.d.ts.map +0 -1
- package/dist/ui/components/misc.js +0 -128
- package/dist/ui/components/misc.js.map +0 -1
- package/dist/ui/components/select-prompt.d.ts +0 -13
- package/dist/ui/components/select-prompt.d.ts.map +0 -1
- package/dist/ui/components/select-prompt.js +0 -42
- package/dist/ui/components/select-prompt.js.map +0 -1
- package/dist/ui/components/status-bar.d.ts +0 -11
- package/dist/ui/components/status-bar.d.ts.map +0 -1
- package/dist/ui/components/status-bar.js +0 -47
- package/dist/ui/components/status-bar.js.map +0 -1
- package/dist/ui/components/tool-execution.d.ts +0 -3
- package/dist/ui/components/tool-execution.d.ts.map +0 -1
- package/dist/ui/components/tool-execution.js +0 -374
- package/dist/ui/components/tool-execution.js.map +0 -1
- package/dist/ui/components/tool-result.d.ts +0 -11
- package/dist/ui/components/tool-result.d.ts.map +0 -1
- package/dist/ui/components/tool-result.js +0 -58
- package/dist/ui/components/tool-result.js.map +0 -1
- package/dist/ui/components/welcome-banner.d.ts +0 -3
- package/dist/ui/components/welcome-banner.d.ts.map +0 -1
- package/dist/ui/components/welcome-banner.js +0 -46
- package/dist/ui/components/welcome-banner.js.map +0 -1
- package/dist/ui/hooks/useDisplayHistory.d.ts +0 -13
- package/dist/ui/hooks/useDisplayHistory.d.ts.map +0 -1
- package/dist/ui/hooks/useDisplayHistory.js +0 -45
- package/dist/ui/hooks/useDisplayHistory.js.map +0 -1
- package/dist/ui/render-engine.d.ts +0 -69
- package/dist/ui/render-engine.d.ts.map +0 -1
- package/dist/ui/render-engine.js +0 -197
- package/dist/ui/render-engine.js.map +0 -1
- package/dist/ui/terminal/TerminalRenderer.d.ts +0 -84
- package/dist/ui/terminal/TerminalRenderer.d.ts.map +0 -1
- package/dist/ui/terminal/TerminalRenderer.js +0 -154
- package/dist/ui/terminal/TerminalRenderer.js.map +0 -1
- package/dist/ui/terminal/TerminalUI.d.ts +0 -139
- package/dist/ui/terminal/TerminalUI.d.ts.map +0 -1
- package/dist/ui/terminal/TerminalUI.js +0 -430
- package/dist/ui/terminal/TerminalUI.js.map +0 -1
- package/dist/ui/terminal/VirtualChatBuffer.d.ts +0 -32
- package/dist/ui/terminal/VirtualChatBuffer.d.ts.map +0 -1
- package/dist/ui/terminal/VirtualChatBuffer.js +0 -37
- package/dist/ui/terminal/VirtualChatBuffer.js.map +0 -1
- package/dist/ui/terminal-kit-base.d.ts +0 -117
- package/dist/ui/terminal-kit-base.d.ts.map +0 -1
- package/dist/ui/terminal-kit-base.js +0 -188
- package/dist/ui/terminal-kit-base.js.map +0 -1
- package/dist/ui/utils/duplication-detector.d.ts +0 -32
- package/dist/ui/utils/duplication-detector.d.ts.map +0 -1
- package/dist/ui/utils/duplication-detector.js +0 -227
- package/dist/ui/utils/duplication-detector.js.map +0 -1
- package/dist/ui/utils/duplication-logger.d.ts +0 -21
- package/dist/ui/utils/duplication-logger.d.ts.map +0 -1
- package/dist/ui/utils/duplication-logger.js +0 -85
- package/dist/ui/utils/duplication-logger.js.map +0 -1
- package/dist/ui/utils/terminal-scanner.d.ts +0 -19
- package/dist/ui/utils/terminal-scanner.d.ts.map +0 -1
- package/dist/ui/utils/terminal-scanner.js +0 -217
- package/dist/ui/utils/terminal-scanner.js.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js +0 -3
- package/dist/version.js.map +0 -1
- package/scripts/generate-version.js +0 -25
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* API Client Service for Centaurus CLI
|
|
3
|
-
*
|
|
4
|
-
* Handles all communication with the backend REST API including:
|
|
5
|
-
* - Authentication and session management
|
|
6
|
-
* - Conversation and message operations
|
|
7
|
-
* - User settings management
|
|
8
|
-
* - API key storage and retrieval
|
|
9
|
-
*/
|
|
10
|
-
import axios from 'axios';
|
|
11
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync, unlinkSync } from 'fs';
|
|
12
|
-
import { join } from 'path';
|
|
13
|
-
import { homedir } from 'os';
|
|
14
|
-
/**
|
|
15
|
-
* API Client class for communicating with the backend service
|
|
16
|
-
*/
|
|
17
|
-
class ApiClient {
|
|
18
|
-
constructor() {
|
|
19
|
-
this.client = null;
|
|
20
|
-
this.sessionToken = null;
|
|
21
|
-
// Set up session storage path: ~/.centaurus/session.json
|
|
22
|
-
this.configDir = join(homedir(), '.centaurus');
|
|
23
|
-
this.configPath = join(this.configDir, 'session.json');
|
|
24
|
-
// Load existing session if available
|
|
25
|
-
this.loadSession();
|
|
26
|
-
// Don't create axios client yet - wait until first use
|
|
27
|
-
// This allows environment variables to be loaded first
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Get or create the axios client instance
|
|
31
|
-
* This is lazy-loaded to ensure environment variables are loaded first
|
|
32
|
-
*/
|
|
33
|
-
getClient() {
|
|
34
|
-
if (!this.client) {
|
|
35
|
-
// Create axios instance with base configuration
|
|
36
|
-
// Use production URL by default, only use localhost in development mode
|
|
37
|
-
const baseURL = process.env.DEV_MODE === 'true'
|
|
38
|
-
? 'http://localhost:3002/api'
|
|
39
|
-
: (process.env.BACKEND_URL || 'https://centaurus-backend-354715948975.asia-south1.run.app/api');
|
|
40
|
-
this.client = axios.create({
|
|
41
|
-
baseURL,
|
|
42
|
-
timeout: 30000,
|
|
43
|
-
headers: {
|
|
44
|
-
'Content-Type': 'application/json',
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
// Request interceptor: Add Authorization header if session token exists
|
|
48
|
-
this.getClient().interceptors.request.use((config) => {
|
|
49
|
-
if (this.sessionToken) {
|
|
50
|
-
config.headers.Authorization = `Bearer ${this.sessionToken}`;
|
|
51
|
-
}
|
|
52
|
-
return config;
|
|
53
|
-
}, (error) => {
|
|
54
|
-
return Promise.reject(error);
|
|
55
|
-
});
|
|
56
|
-
// Response interceptor: Handle 401 errors (expired/invalid session)
|
|
57
|
-
this.getClient().interceptors.response.use((response) => response, async (error) => {
|
|
58
|
-
if (error.response?.status === 401) {
|
|
59
|
-
// Clear invalid session
|
|
60
|
-
this.clearSession();
|
|
61
|
-
// Create a more user-friendly error
|
|
62
|
-
const authError = new Error('Session expired. Please sign in again.');
|
|
63
|
-
authError.name = 'AuthenticationError';
|
|
64
|
-
throw authError;
|
|
65
|
-
}
|
|
66
|
-
// For other errors, extract message from API response if available
|
|
67
|
-
if (error.response?.data) {
|
|
68
|
-
const apiError = error.response.data;
|
|
69
|
-
if (apiError.error) {
|
|
70
|
-
const customError = new Error(apiError.error.message);
|
|
71
|
-
customError.name = apiError.error.code;
|
|
72
|
-
throw customError;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
throw error;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return this.client;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Load session token from local config file
|
|
82
|
-
*/
|
|
83
|
-
loadSession() {
|
|
84
|
-
try {
|
|
85
|
-
if (existsSync(this.configPath)) {
|
|
86
|
-
const data = readFileSync(this.configPath, 'utf-8');
|
|
87
|
-
const session = JSON.parse(data);
|
|
88
|
-
this.sessionToken = session.sessionToken || null;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
// If there's any error reading the session, just start fresh
|
|
93
|
-
this.sessionToken = null;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Save session token to local config file
|
|
98
|
-
*/
|
|
99
|
-
saveSession(token, expiresAt) {
|
|
100
|
-
try {
|
|
101
|
-
// Ensure config directory exists
|
|
102
|
-
if (!existsSync(this.configDir)) {
|
|
103
|
-
mkdirSync(this.configDir, { recursive: true });
|
|
104
|
-
}
|
|
105
|
-
// Save session data
|
|
106
|
-
const sessionData = {
|
|
107
|
-
sessionToken: token,
|
|
108
|
-
expiresAt: expiresAt || null,
|
|
109
|
-
savedAt: new Date().toISOString(),
|
|
110
|
-
};
|
|
111
|
-
writeFileSync(this.configPath, JSON.stringify(sessionData, null, 2), 'utf-8');
|
|
112
|
-
this.sessionToken = token;
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
console.error('Failed to save session:', error);
|
|
116
|
-
throw new Error('Failed to save session locally');
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Clear session token from memory and local storage
|
|
121
|
-
*/
|
|
122
|
-
clearSession() {
|
|
123
|
-
this.sessionToken = null;
|
|
124
|
-
try {
|
|
125
|
-
if (existsSync(this.configPath)) {
|
|
126
|
-
unlinkSync(this.configPath);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
// Ignore errors when clearing session
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Check if user is authenticated
|
|
135
|
-
*/
|
|
136
|
-
isAuthenticated() {
|
|
137
|
-
return this.sessionToken !== null;
|
|
138
|
-
}
|
|
139
|
-
// ==================== Authentication Methods ====================
|
|
140
|
-
/**
|
|
141
|
-
* Initialize Google OAuth flow
|
|
142
|
-
* @param redirectUri - The URI to redirect to after OAuth
|
|
143
|
-
* @returns OAuth URL and state parameter
|
|
144
|
-
*/
|
|
145
|
-
async initGoogleAuth(redirectUri) {
|
|
146
|
-
const response = await this.getClient().post('/auth/google/init', { redirectUri });
|
|
147
|
-
return response.data.data;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Complete Google OAuth authentication
|
|
151
|
-
* @param code - Authorization code from Google
|
|
152
|
-
* @param state - State parameter for CSRF protection
|
|
153
|
-
* @returns Session token and user information
|
|
154
|
-
*/
|
|
155
|
-
async authenticate(code, state) {
|
|
156
|
-
const response = await this.getClient().post('/auth/google/callback', { code, state });
|
|
157
|
-
const authData = response.data.data;
|
|
158
|
-
this.saveSession(authData.sessionToken, authData.expiresAt);
|
|
159
|
-
return authData;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Set session token directly (used when receiving token from web app)
|
|
163
|
-
* @param sessionToken - The session token to save
|
|
164
|
-
* @param user - User information
|
|
165
|
-
*/
|
|
166
|
-
setSessionToken(sessionToken, user) {
|
|
167
|
-
// Calculate expiration (30 days from now)
|
|
168
|
-
const expiresAt = new Date();
|
|
169
|
-
expiresAt.setDate(expiresAt.getDate() + 30);
|
|
170
|
-
this.saveSession(sessionToken, expiresAt.toISOString());
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Refresh the current session token
|
|
174
|
-
* @returns New session token and expiration
|
|
175
|
-
*/
|
|
176
|
-
async refreshSession() {
|
|
177
|
-
const response = await this.getClient().post('/auth/refresh');
|
|
178
|
-
const refreshData = response.data.data;
|
|
179
|
-
this.saveSession(refreshData.sessionToken, refreshData.expiresAt);
|
|
180
|
-
return refreshData;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Logout and invalidate current session
|
|
184
|
-
*/
|
|
185
|
-
async logout() {
|
|
186
|
-
try {
|
|
187
|
-
await this.getClient().post('/auth/logout');
|
|
188
|
-
}
|
|
189
|
-
finally {
|
|
190
|
-
// Always clear local session, even if API call fails
|
|
191
|
-
this.clearSession();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Get current authenticated user profile
|
|
196
|
-
* @returns User profile information
|
|
197
|
-
*/
|
|
198
|
-
async getCurrentUser() {
|
|
199
|
-
const response = await this.getClient().get('/auth/me');
|
|
200
|
-
return response.data.data;
|
|
201
|
-
}
|
|
202
|
-
// ==================== Conversation Methods ====================
|
|
203
|
-
/**
|
|
204
|
-
* Create a new conversation
|
|
205
|
-
* @param data - Conversation creation parameters
|
|
206
|
-
* @returns Created conversation
|
|
207
|
-
*/
|
|
208
|
-
async createConversation(data) {
|
|
209
|
-
const response = await this.getClient().post('/conversations', data);
|
|
210
|
-
return response.data.data;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Get all conversations for the authenticated user
|
|
214
|
-
* @param params - Pagination and filter parameters
|
|
215
|
-
* @returns List of conversations with pagination metadata
|
|
216
|
-
*/
|
|
217
|
-
async getConversations(params) {
|
|
218
|
-
const queryParams = {
|
|
219
|
-
page: params?.page || 1,
|
|
220
|
-
limit: params?.limit || 20,
|
|
221
|
-
};
|
|
222
|
-
if (params?.includeArchived !== undefined) {
|
|
223
|
-
queryParams.includeArchived = params.includeArchived;
|
|
224
|
-
}
|
|
225
|
-
if (params?.tags && params.tags.length > 0) {
|
|
226
|
-
queryParams.tags = params.tags.join(',');
|
|
227
|
-
}
|
|
228
|
-
const response = await this.getClient().get('/conversations', { params: queryParams });
|
|
229
|
-
return response.data;
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Get a specific conversation by ID
|
|
233
|
-
* @param conversationId - The conversation ID
|
|
234
|
-
* @returns Conversation details
|
|
235
|
-
*/
|
|
236
|
-
async getConversation(conversationId) {
|
|
237
|
-
const response = await this.getClient().get(`/conversations/${conversationId}`);
|
|
238
|
-
return response.data.data;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Update a conversation
|
|
242
|
-
* @param conversationId - The conversation ID
|
|
243
|
-
* @param data - Fields to update
|
|
244
|
-
* @returns Updated conversation
|
|
245
|
-
*/
|
|
246
|
-
async updateConversation(conversationId, data) {
|
|
247
|
-
const response = await this.getClient().put(`/conversations/${conversationId}`, data);
|
|
248
|
-
return response.data.data;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Delete (archive) a conversation
|
|
252
|
-
* @param conversationId - The conversation ID
|
|
253
|
-
*/
|
|
254
|
-
async deleteConversation(conversationId) {
|
|
255
|
-
await this.getClient().delete(`/conversations/${conversationId}`);
|
|
256
|
-
}
|
|
257
|
-
// ==================== Message Methods ====================
|
|
258
|
-
/**
|
|
259
|
-
* Add a message to a conversation
|
|
260
|
-
* @param conversationId - The conversation ID
|
|
261
|
-
* @param message - Message data
|
|
262
|
-
* @returns Created message
|
|
263
|
-
*/
|
|
264
|
-
async addMessage(conversationId, message) {
|
|
265
|
-
const response = await this.getClient().post(`/conversations/${conversationId}/messages`, message);
|
|
266
|
-
return response.data.data;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Get all messages for a conversation
|
|
270
|
-
* @param conversationId - The conversation ID
|
|
271
|
-
* @param params - Pagination parameters
|
|
272
|
-
* @returns List of messages with pagination metadata
|
|
273
|
-
*/
|
|
274
|
-
async getMessages(conversationId, params) {
|
|
275
|
-
const queryParams = {
|
|
276
|
-
page: params?.page || 1,
|
|
277
|
-
limit: params?.limit || 50,
|
|
278
|
-
};
|
|
279
|
-
const response = await this.getClient().get(`/conversations/${conversationId}/messages`, { params: queryParams });
|
|
280
|
-
return response.data;
|
|
281
|
-
}
|
|
282
|
-
// ==================== Settings Methods ====================
|
|
283
|
-
/**
|
|
284
|
-
* Get user settings
|
|
285
|
-
* @returns User settings object
|
|
286
|
-
*/
|
|
287
|
-
async getSettings() {
|
|
288
|
-
const response = await this.getClient().get('/settings');
|
|
289
|
-
return response.data.data;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Update user settings
|
|
293
|
-
* @param settings - Settings to update (partial update supported)
|
|
294
|
-
* @returns Updated settings
|
|
295
|
-
*/
|
|
296
|
-
async updateSettings(settings) {
|
|
297
|
-
const response = await this.getClient().put('/settings', settings);
|
|
298
|
-
return response.data.data;
|
|
299
|
-
}
|
|
300
|
-
// ==================== API Key Methods ====================
|
|
301
|
-
/**
|
|
302
|
-
* Store an encrypted API key
|
|
303
|
-
* @param data - API key data including provider, name, and key value
|
|
304
|
-
* @returns API key metadata (without the actual key)
|
|
305
|
-
*/
|
|
306
|
-
async storeApiKey(data) {
|
|
307
|
-
const response = await this.getClient().post('/api-keys', data);
|
|
308
|
-
return response.data.data;
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Get all API keys (metadata only, not actual keys)
|
|
312
|
-
* @returns List of API key metadata
|
|
313
|
-
*/
|
|
314
|
-
async getApiKeys() {
|
|
315
|
-
const response = await this.getClient().get('/api-keys');
|
|
316
|
-
return response.data.data;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Decrypt and retrieve an API key for a specific provider
|
|
320
|
-
* @param provider - The provider name
|
|
321
|
-
* @returns Decrypted API key
|
|
322
|
-
*/
|
|
323
|
-
async decryptApiKey(provider) {
|
|
324
|
-
const response = await this.getClient().get(`/api-keys/${provider}/decrypt`);
|
|
325
|
-
return response.data.data;
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Delete an API key
|
|
329
|
-
* @param keyId - The API key ID
|
|
330
|
-
*/
|
|
331
|
-
async deleteApiKey(keyId) {
|
|
332
|
-
await this.getClient().delete(`/api-keys/${keyId}`);
|
|
333
|
-
}
|
|
334
|
-
// ==================== Health Check ====================
|
|
335
|
-
/**
|
|
336
|
-
* Check backend service health
|
|
337
|
-
* @returns Health status information
|
|
338
|
-
*/
|
|
339
|
-
async healthCheck() {
|
|
340
|
-
// Health endpoint is at root level, not under /api
|
|
341
|
-
// So we need to construct the full URL manually
|
|
342
|
-
const baseURL = process.env.BACKEND_API_URL || 'http://localhost:3000/api';
|
|
343
|
-
const healthURL = baseURL.replace('/api', '/health');
|
|
344
|
-
const response = await axios.get(healthURL);
|
|
345
|
-
return response.data.data;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
// Export singleton instance
|
|
349
|
-
export const apiClient = new ApiClient();
|
package/dist/test/tools/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/test/types/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple test script for AI Context Injector
|
|
3
|
-
*/
|
|
4
|
-
import { AIContextInjector } from './src/services/ai-context-injector.js';
|
|
5
|
-
console.log('Testing AI Context Injector...\n');
|
|
6
|
-
const injector = new AIContextInjector();
|
|
7
|
-
// Test 1: Local context (no injection)
|
|
8
|
-
console.log('Test 1: Local context (no injection)');
|
|
9
|
-
const localMessages = [
|
|
10
|
-
{ role: 'user', content: 'Hello' },
|
|
11
|
-
{ role: 'assistant', content: 'Hi!' },
|
|
12
|
-
];
|
|
13
|
-
const localContext = {
|
|
14
|
-
type: 'local',
|
|
15
|
-
metadata: {
|
|
16
|
-
workingDirectory: '/home/user',
|
|
17
|
-
shell: 'bash',
|
|
18
|
-
os: 'linux',
|
|
19
|
-
},
|
|
20
|
-
connectionState: 'connected',
|
|
21
|
-
sessionId: 'local',
|
|
22
|
-
};
|
|
23
|
-
const localResult = injector.injectSubshellContext(localMessages, localContext);
|
|
24
|
-
console.log(` Original messages: ${localMessages.length}`);
|
|
25
|
-
console.log(` Result messages: ${localResult.length}`);
|
|
26
|
-
console.log(` ✓ No injection for local context\n`);
|
|
27
|
-
// Test 2: SSH context injection
|
|
28
|
-
console.log('Test 2: SSH context injection');
|
|
29
|
-
const sshMessages = [
|
|
30
|
-
{ role: 'user', content: 'List files' },
|
|
31
|
-
];
|
|
32
|
-
const sshContext = {
|
|
33
|
-
type: 'ssh',
|
|
34
|
-
metadata: {
|
|
35
|
-
hostname: 'example.com',
|
|
36
|
-
username: 'testuser',
|
|
37
|
-
workingDirectory: '/home/testuser',
|
|
38
|
-
shell: 'bash',
|
|
39
|
-
os: 'linux',
|
|
40
|
-
port: 22,
|
|
41
|
-
},
|
|
42
|
-
connectionState: 'connected',
|
|
43
|
-
sessionId: 'ssh-123',
|
|
44
|
-
};
|
|
45
|
-
const sshResult = injector.injectSubshellContext(sshMessages, sshContext);
|
|
46
|
-
console.log(` Original messages: ${sshMessages.length}`);
|
|
47
|
-
console.log(` Result messages: ${sshResult.length}`);
|
|
48
|
-
console.log(` Context message role: ${sshResult[0].role}`);
|
|
49
|
-
console.log(` Context includes SSH: ${sshResult[0].content.includes('SSH')}`);
|
|
50
|
-
console.log(` Context includes hostname: ${sshResult[0].content.includes('example.com')}`);
|
|
51
|
-
console.log(` Context includes username: ${sshResult[0].content.includes('testuser')}`);
|
|
52
|
-
console.log(` ✓ SSH context injected correctly\n`);
|
|
53
|
-
// Test 3: WSL context injection
|
|
54
|
-
console.log('Test 3: WSL context injection');
|
|
55
|
-
const wslMessages = [
|
|
56
|
-
{ role: 'user', content: 'Check files' },
|
|
57
|
-
];
|
|
58
|
-
const wslContext = {
|
|
59
|
-
type: 'wsl',
|
|
60
|
-
metadata: {
|
|
61
|
-
distroName: 'Ubuntu-20.04',
|
|
62
|
-
workingDirectory: '/home/user',
|
|
63
|
-
shell: 'bash',
|
|
64
|
-
os: 'linux',
|
|
65
|
-
},
|
|
66
|
-
connectionState: 'connected',
|
|
67
|
-
sessionId: 'wsl-456',
|
|
68
|
-
};
|
|
69
|
-
const wslResult = injector.injectSubshellContext(wslMessages, wslContext);
|
|
70
|
-
console.log(` Original messages: ${wslMessages.length}`);
|
|
71
|
-
console.log(` Result messages: ${wslResult.length}`);
|
|
72
|
-
console.log(` Context includes WSL: ${wslResult[0].content.includes('WSL')}`);
|
|
73
|
-
console.log(` Context includes distro: ${wslResult[0].content.includes('Ubuntu-20.04')}`);
|
|
74
|
-
console.log(` ✓ WSL context injected correctly\n`);
|
|
75
|
-
// Test 4: Docker context injection
|
|
76
|
-
console.log('Test 4: Docker context injection');
|
|
77
|
-
const dockerMessages = [
|
|
78
|
-
{ role: 'user', content: 'Run command' },
|
|
79
|
-
];
|
|
80
|
-
const dockerContext = {
|
|
81
|
-
type: 'docker',
|
|
82
|
-
metadata: {
|
|
83
|
-
containerId: 'abc123',
|
|
84
|
-
workingDirectory: '/app',
|
|
85
|
-
shell: 'sh',
|
|
86
|
-
os: 'linux',
|
|
87
|
-
},
|
|
88
|
-
connectionState: 'connected',
|
|
89
|
-
sessionId: 'docker-789',
|
|
90
|
-
};
|
|
91
|
-
const dockerResult = injector.injectSubshellContext(dockerMessages, dockerContext);
|
|
92
|
-
console.log(` Original messages: ${dockerMessages.length}`);
|
|
93
|
-
console.log(` Result messages: ${dockerResult.length}`);
|
|
94
|
-
console.log(` Context includes DOCKER: ${dockerResult[0].content.includes('DOCKER')}`);
|
|
95
|
-
console.log(` Context includes container: ${dockerResult[0].content.includes('abc123')}`);
|
|
96
|
-
console.log(` ✓ Docker context injected correctly\n`);
|
|
97
|
-
console.log('All tests passed! ✓');
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Automated Functionality Verification Tests
|
|
3
|
-
*
|
|
4
|
-
* This script tests core functionality of Centaurus CLI to ensure
|
|
5
|
-
* all features work correctly after the UI rendering refactor.
|
|
6
|
-
*/
|
|
7
|
-
declare class TestRunner {
|
|
8
|
-
private results;
|
|
9
|
-
private cli;
|
|
10
|
-
private testDir;
|
|
11
|
-
constructor();
|
|
12
|
-
setup(): Promise<void>;
|
|
13
|
-
cleanup(): Promise<void>;
|
|
14
|
-
runTest(name: string, testFn: () => Promise<void>): Promise<void>;
|
|
15
|
-
printSummary(): void;
|
|
16
|
-
testSlashCommands(): Promise<void>;
|
|
17
|
-
testToolRegistry(): Promise<void>;
|
|
18
|
-
testStreamingCallbacks(): Promise<void>;
|
|
19
|
-
testToolExecutionCallbacks(): Promise<void>;
|
|
20
|
-
testConfiguration(): Promise<void>;
|
|
21
|
-
testPickerCallbacks(): Promise<void>;
|
|
22
|
-
testPlanModeCallbacks(): Promise<void>;
|
|
23
|
-
testFileOperations(): Promise<void>;
|
|
24
|
-
runAllTests(): Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
export { TestRunner };
|
|
27
|
-
//# sourceMappingURL=automated-verification.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"automated-verification.d.ts","sourceRoot":"","sources":["../../src/tests/automated-verification.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,cAAM,UAAU;IACd,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,GAAG,CAAe;IAC1B,OAAO,CAAC,OAAO,CAAS;;IAOlB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IActB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAWxB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBvE,YAAY,IAAI,IAAI;IA6Bd,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAuGlC,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAgCjC,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBvC,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB3C,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBlC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAwDpC,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAkCtC,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IA6BnC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CA0BnC;AASD,OAAO,EAAE,UAAU,EAAE,CAAC"}
|