@vybestack/llxprt-code 0.1.15 → 0.1.16
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/README.md +37 -2
- package/dist/package.json +3 -3
- package/dist/src/config/config.d.ts +4 -1
- package/dist/src/config/config.js +151 -54
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/settings.d.ts +11 -2
- package/dist/src/config/settings.js +84 -23
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/gemini.d.ts +2 -0
- package/dist/src/gemini.js +177 -21
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +1 -1
- package/dist/src/generated/git-commit.js +1 -1
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/integration-tests/GITHUB_ACTIONS_README.md +41 -0
- package/dist/src/integration-tests/test-utils.d.ts +68 -0
- package/dist/src/integration-tests/test-utils.js +167 -0
- package/dist/src/integration-tests/test-utils.js.map +1 -0
- package/dist/src/nonInteractiveCli.js +24 -66
- package/dist/src/nonInteractiveCli.js.map +1 -1
- package/dist/src/providers/IFileSystem.d.ts +42 -0
- package/dist/src/providers/IFileSystem.js +46 -0
- package/dist/src/providers/IFileSystem.js.map +1 -0
- package/dist/src/providers/providerConfigUtils.d.ts +0 -4
- package/dist/src/providers/providerConfigUtils.js +21 -52
- package/dist/src/providers/providerConfigUtils.js.map +1 -1
- package/dist/src/providers/providerManagerInstance.d.ts +6 -1
- package/dist/src/providers/providerManagerInstance.js +117 -82
- package/dist/src/providers/providerManagerInstance.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.js +11 -0
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/ui/App.js +61 -48
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/commands/aboutCommand.js +2 -5
- package/dist/src/ui/commands/aboutCommand.js.map +1 -1
- package/dist/src/ui/commands/baseurlCommand.js +54 -9
- package/dist/src/ui/commands/baseurlCommand.js.map +1 -1
- package/dist/src/ui/commands/diagnosticsCommand.d.ts +10 -0
- package/dist/src/ui/commands/diagnosticsCommand.js +122 -0
- package/dist/src/ui/commands/diagnosticsCommand.js.map +1 -0
- package/dist/src/ui/commands/directoryCommand.d.ts +8 -0
- package/dist/src/ui/commands/directoryCommand.js +116 -0
- package/dist/src/ui/commands/directoryCommand.js.map +1 -0
- package/dist/src/ui/commands/ideCommand.js +101 -105
- package/dist/src/ui/commands/ideCommand.js.map +1 -1
- package/dist/src/ui/commands/initCommand.js +63 -31
- package/dist/src/ui/commands/initCommand.js.map +1 -1
- package/dist/src/ui/commands/keyCommand.js +75 -11
- package/dist/src/ui/commands/keyCommand.js.map +1 -1
- package/dist/src/ui/commands/keyfileCommand.js +54 -13
- package/dist/src/ui/commands/keyfileCommand.js.map +1 -1
- package/dist/src/ui/commands/memoryCommand.js +2 -1
- package/dist/src/ui/commands/memoryCommand.js.map +1 -1
- package/dist/src/ui/commands/modelCommand.js +2 -5
- package/dist/src/ui/commands/modelCommand.js.map +1 -1
- package/dist/src/ui/commands/profileCommand.d.ts +10 -0
- package/dist/src/ui/commands/profileCommand.js +592 -0
- package/dist/src/ui/commands/profileCommand.js.map +1 -0
- package/dist/src/ui/commands/providerCommand.js +46 -3
- package/dist/src/ui/commands/providerCommand.js.map +1 -1
- package/dist/src/ui/commands/setCommand.d.ts +7 -0
- package/dist/src/ui/commands/setCommand.js +431 -0
- package/dist/src/ui/commands/setCommand.js.map +1 -0
- package/dist/src/ui/commands/setupGithubCommand.d.ts +7 -0
- package/dist/src/ui/commands/setupGithubCommand.js +49 -0
- package/dist/src/ui/commands/setupGithubCommand.js.map +1 -0
- package/dist/src/ui/commands/types.d.ts +1 -1
- package/dist/src/ui/commands/types.js.map +1 -1
- package/dist/src/ui/components/DebugProfiler.d.ts +6 -0
- package/dist/src/ui/components/DebugProfiler.js +26 -0
- package/dist/src/ui/components/DebugProfiler.js.map +1 -0
- package/dist/src/ui/components/Footer.d.ts +1 -0
- package/dist/src/ui/components/Footer.js +5 -4
- package/dist/src/ui/components/Footer.js.map +1 -1
- package/dist/src/ui/components/IDEContextDetailDisplay.d.ts +2 -1
- package/dist/src/ui/components/IDEContextDetailDisplay.js +3 -3
- package/dist/src/ui/components/IDEContextDetailDisplay.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.js +123 -12
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/LoadProfileDialog.d.ts +13 -0
- package/dist/src/ui/components/LoadProfileDialog.js +57 -0
- package/dist/src/ui/components/LoadProfileDialog.js.map +1 -0
- package/dist/src/ui/components/PrepareLabel.d.ts +15 -0
- package/dist/src/ui/components/PrepareLabel.js +16 -0
- package/dist/src/ui/components/PrepareLabel.js.map +1 -0
- package/dist/src/ui/components/ProviderModelDialog.js +75 -28
- package/dist/src/ui/components/ProviderModelDialog.js.map +1 -1
- package/dist/src/ui/components/SecureKeyInput.d.ts +15 -0
- package/dist/src/ui/components/SecureKeyInput.js +58 -0
- package/dist/src/ui/components/SecureKeyInput.js.map +1 -0
- package/dist/src/ui/components/SuggestionsDisplay.d.ts +1 -0
- package/dist/src/ui/components/SuggestionsDisplay.js +3 -3
- package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js +15 -4
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
- package/dist/src/ui/components/messages/UserMessage.js +4 -1
- package/dist/src/ui/components/messages/UserMessage.js.map +1 -1
- package/dist/src/ui/components/shared/text-buffer.js +9 -14
- package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
- package/dist/src/ui/containers/SessionController.js +14 -15
- package/dist/src/ui/containers/SessionController.js.map +1 -1
- package/dist/src/ui/editors/editorSettingsManager.js +2 -0
- package/dist/src/ui/editors/editorSettingsManager.js.map +1 -1
- package/dist/src/ui/hooks/atCommandProcessor.js +56 -48
- package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.js +13 -3
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useAuthCommand.js +9 -0
- package/dist/src/ui/hooks/useAuthCommand.js.map +1 -1
- package/dist/src/ui/hooks/useCompletion.d.ts +5 -5
- package/dist/src/ui/hooks/useCompletion.js +7 -407
- package/dist/src/ui/hooks/useCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.js +44 -10
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useLoadProfileDialog.d.ts +27 -0
- package/dist/src/ui/hooks/useLoadProfileDialog.js +138 -0
- package/dist/src/ui/hooks/useLoadProfileDialog.js.map +1 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.d.ts +19 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.js +54 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.js.map +1 -0
- package/dist/src/ui/hooks/useShellHistory.d.ts +1 -0
- package/dist/src/ui/hooks/useShellHistory.js +30 -7
- package/dist/src/ui/hooks/useShellHistory.js.map +1 -1
- package/dist/src/ui/hooks/useSlashCompletion.d.ts +24 -0
- package/dist/src/ui/hooks/useSlashCompletion.js +451 -0
- package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -0
- package/dist/src/ui/reducers/appReducer.d.ts +3 -2
- package/dist/src/ui/reducers/appReducer.js +1 -0
- package/dist/src/ui/reducers/appReducer.js.map +1 -1
- package/dist/src/ui/utils/renderLoopDetector.js +3 -3
- package/dist/src/ui/utils/renderLoopDetector.js.map +1 -1
- package/dist/src/ui/utils/secureInputHandler.d.ts +46 -0
- package/dist/src/ui/utils/secureInputHandler.js +128 -0
- package/dist/src/ui/utils/secureInputHandler.js.map +1 -0
- package/dist/src/ui/utils/updateCheck.js +57 -12
- package/dist/src/ui/utils/updateCheck.js.map +1 -1
- package/dist/src/utils/gitUtils.d.ts +10 -0
- package/dist/src/utils/gitUtils.js +24 -0
- package/dist/src/utils/gitUtils.js.map +1 -0
- package/dist/src/utils/handleAutoUpdate.d.ts +2 -1
- package/dist/src/utils/handleAutoUpdate.js +8 -4
- package/dist/src/utils/handleAutoUpdate.js.map +1 -1
- package/dist/src/utils/sandbox-macos-permissive-closed.sb +6 -0
- package/dist/src/utils/sandbox-macos-permissive-open.sb +6 -0
- package/dist/src/utils/sandbox-macos-permissive-proxied.sb +6 -0
- package/dist/src/utils/sandbox-macos-restrictive-closed.sb +6 -0
- package/dist/src/utils/sandbox-macos-restrictive-open.sb +6 -0
- package/dist/src/utils/sandbox-macos-restrictive-proxied.sb +6 -0
- package/dist/src/utils/sandbox.d.ts +2 -2
- package/dist/src/utils/sandbox.js +35 -11
- package/dist/src/utils/sandbox.js.map +1 -1
- package/dist/src/utils/spawnWrapper.d.ts +7 -0
- package/dist/src/utils/spawnWrapper.js +8 -0
- package/dist/src/utils/spawnWrapper.js.map +1 -0
- package/dist/src/validateNonInterActiveAuth.d.ts +2 -1
- package/dist/src/validateNonInterActiveAuth.js +31 -5
- package/dist/src/validateNonInterActiveAuth.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/src/providers/enhanceConfigWithProviders.d.ts +0 -12
- package/dist/src/providers/enhanceConfigWithProviders.js +0 -16
- package/dist/src/providers/enhanceConfigWithProviders.js.map +0 -1
@@ -0,0 +1,41 @@
|
|
1
|
+
# Running Integration Tests in GitHub Actions
|
2
|
+
|
3
|
+
The CLI integration tests spawn actual CLI processes to test real behavior. To prevent browser windows from opening during authentication in CI environments, the following environment variables are set:
|
4
|
+
|
5
|
+
## Environment Variables for CI
|
6
|
+
|
7
|
+
```yaml
|
8
|
+
env:
|
9
|
+
CI: 'true'
|
10
|
+
LLXPRT_NO_BROWSER_AUTH: 'true'
|
11
|
+
GITHUB_ACTIONS: 'true'
|
12
|
+
DISPLAY: '' # No display available
|
13
|
+
```
|
14
|
+
|
15
|
+
## Test Configuration
|
16
|
+
|
17
|
+
1. **Timeouts**: Tests use a 5-second timeout to prevent hanging
|
18
|
+
2. **Authentication**: Tests provide API keys via keyfiles to avoid triggering OAuth flows
|
19
|
+
3. **Home Directory**: Tests use temporary directories to isolate profile loading
|
20
|
+
|
21
|
+
## Key Points
|
22
|
+
|
23
|
+
- The `CI` and `LLXPRT_NO_BROWSER_AUTH` environment variables should prevent browser-based authentication
|
24
|
+
- All tests that spawn CLI processes should provide authentication (via `--key` or `--keyfile`) to avoid auth prompts
|
25
|
+
- Tests should complete quickly (within 5 seconds) or they'll be killed with exitCode -1
|
26
|
+
|
27
|
+
## Running Tests Locally
|
28
|
+
|
29
|
+
To run integration tests locally without opening browser windows:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
CI=true LLXPRT_NO_BROWSER_AUTH=true npm test
|
33
|
+
```
|
34
|
+
|
35
|
+
## Troubleshooting
|
36
|
+
|
37
|
+
If browser windows still open:
|
38
|
+
|
39
|
+
1. Check that the CLI respects the `LLXPRT_NO_BROWSER_AUTH` environment variable
|
40
|
+
2. Ensure all test cases provide proper authentication
|
41
|
+
3. Consider mocking the authentication flow in test environments
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2025 Vybestack LLC
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
5
|
+
*/
|
6
|
+
import * as http from 'http';
|
7
|
+
import { Profile } from '@vybestack/llxprt-code-core';
|
8
|
+
/**
|
9
|
+
* Creates a temporary directory for tests
|
10
|
+
* @returns Path to the created temporary directory
|
11
|
+
*/
|
12
|
+
export declare function createTempDirectory(): Promise<string>;
|
13
|
+
/**
|
14
|
+
* Cleans up a temporary directory and all its contents
|
15
|
+
* @param dir - Directory path to clean up
|
16
|
+
*/
|
17
|
+
export declare function cleanupTempDirectory(dir: string): Promise<void>;
|
18
|
+
/**
|
19
|
+
* Creates a profile file in the specified directory
|
20
|
+
* @param dir - Directory to create the profile in
|
21
|
+
* @param name - Name of the profile (without .json extension)
|
22
|
+
* @param profile - Profile data to write
|
23
|
+
*/
|
24
|
+
export declare function createTempProfile(dir: string, name: string, profile: Profile): Promise<void>;
|
25
|
+
/**
|
26
|
+
* Creates a keyfile with proper permissions (600)
|
27
|
+
* @param dir - Directory to create the keyfile in
|
28
|
+
* @param apiKey - API key content to write
|
29
|
+
* @returns Path to the created keyfile
|
30
|
+
*/
|
31
|
+
export declare function createTempKeyfile(dir: string, apiKey: string): Promise<string>;
|
32
|
+
/**
|
33
|
+
* Reads and parses settings.json from the specified directory
|
34
|
+
* @param dir - Directory containing .llxprt/settings.json
|
35
|
+
* @returns Parsed settings object
|
36
|
+
*/
|
37
|
+
export declare function readSettingsFile(dir: string): Promise<unknown>;
|
38
|
+
/**
|
39
|
+
* Writes settings.json to the specified directory
|
40
|
+
* @param dir - Directory to write .llxprt/settings.json in
|
41
|
+
* @param settings - Settings object to write
|
42
|
+
*/
|
43
|
+
export declare function writeSettingsFile(dir: string, settings: unknown): Promise<void>;
|
44
|
+
/**
|
45
|
+
* Waits for a file to exist with timeout
|
46
|
+
* @param filepath - Path to the file to wait for
|
47
|
+
* @param timeout - Maximum time to wait in milliseconds
|
48
|
+
* @returns Promise that resolves when file exists or rejects on timeout
|
49
|
+
*/
|
50
|
+
export declare function waitForFile(filepath: string, timeout: number): Promise<void>;
|
51
|
+
interface MockApiServerRequest {
|
52
|
+
method?: string;
|
53
|
+
url?: string;
|
54
|
+
headers: http.IncomingHttpHeaders;
|
55
|
+
body: string;
|
56
|
+
}
|
57
|
+
interface MockApiServer {
|
58
|
+
server: http.Server;
|
59
|
+
port: number;
|
60
|
+
requests: MockApiServerRequest[];
|
61
|
+
close: () => Promise<void>;
|
62
|
+
}
|
63
|
+
/**
|
64
|
+
* Creates a simple HTTP server that logs requests
|
65
|
+
* @returns Mock server object with server instance, port, and request log
|
66
|
+
*/
|
67
|
+
export declare function createMockApiServer(): Promise<MockApiServer>;
|
68
|
+
export {};
|
@@ -0,0 +1,167 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2025 Vybestack LLC
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
5
|
+
*/
|
6
|
+
import * as fs from 'fs/promises';
|
7
|
+
import * as path from 'path';
|
8
|
+
import * as os from 'os';
|
9
|
+
import * as http from 'http';
|
10
|
+
/**
|
11
|
+
* Creates a temporary directory for tests
|
12
|
+
* @returns Path to the created temporary directory
|
13
|
+
*/
|
14
|
+
export async function createTempDirectory() {
|
15
|
+
const prefix = 'llxprt-test-';
|
16
|
+
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), prefix));
|
17
|
+
return tempDir;
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* Cleans up a temporary directory and all its contents
|
21
|
+
* @param dir - Directory path to clean up
|
22
|
+
*/
|
23
|
+
export async function cleanupTempDirectory(dir) {
|
24
|
+
try {
|
25
|
+
await fs.rm(dir, { recursive: true, force: true });
|
26
|
+
}
|
27
|
+
catch (error) {
|
28
|
+
// Ignore errors if directory doesn't exist
|
29
|
+
if (error &&
|
30
|
+
typeof error === 'object' &&
|
31
|
+
'code' in error &&
|
32
|
+
error.code !== 'ENOENT') {
|
33
|
+
throw error;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
/**
|
38
|
+
* Creates a profile file in the specified directory
|
39
|
+
* @param dir - Directory to create the profile in
|
40
|
+
* @param name - Name of the profile (without .json extension)
|
41
|
+
* @param profile - Profile data to write
|
42
|
+
*/
|
43
|
+
export async function createTempProfile(dir, name, profile) {
|
44
|
+
const profilesDir = path.join(dir, '.llxprt', 'profiles');
|
45
|
+
await fs.mkdir(profilesDir, { recursive: true });
|
46
|
+
const profilePath = path.join(profilesDir, `${name}.json`);
|
47
|
+
await fs.writeFile(profilePath, JSON.stringify(profile, null, 2), 'utf8');
|
48
|
+
}
|
49
|
+
/**
|
50
|
+
* Creates a keyfile with proper permissions (600)
|
51
|
+
* @param dir - Directory to create the keyfile in
|
52
|
+
* @param apiKey - API key content to write
|
53
|
+
* @returns Path to the created keyfile
|
54
|
+
*/
|
55
|
+
export async function createTempKeyfile(dir, apiKey) {
|
56
|
+
const keysDir = path.join(dir, '.keys');
|
57
|
+
await fs.mkdir(keysDir, { recursive: true });
|
58
|
+
const keyfilePath = path.join(keysDir, 'api-key');
|
59
|
+
await fs.writeFile(keyfilePath, apiKey, { mode: 0o600 });
|
60
|
+
return keyfilePath;
|
61
|
+
}
|
62
|
+
/**
|
63
|
+
* Reads and parses settings.json from the specified directory
|
64
|
+
* @param dir - Directory containing .llxprt/settings.json
|
65
|
+
* @returns Parsed settings object
|
66
|
+
*/
|
67
|
+
export async function readSettingsFile(dir) {
|
68
|
+
const settingsPath = path.join(dir, '.llxprt', 'settings.json');
|
69
|
+
try {
|
70
|
+
const content = await fs.readFile(settingsPath, 'utf8');
|
71
|
+
return JSON.parse(content);
|
72
|
+
}
|
73
|
+
catch (error) {
|
74
|
+
if (error &&
|
75
|
+
typeof error === 'object' &&
|
76
|
+
'code' in error &&
|
77
|
+
error.code === 'ENOENT') {
|
78
|
+
return {};
|
79
|
+
}
|
80
|
+
throw error;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
/**
|
84
|
+
* Writes settings.json to the specified directory
|
85
|
+
* @param dir - Directory to write .llxprt/settings.json in
|
86
|
+
* @param settings - Settings object to write
|
87
|
+
*/
|
88
|
+
export async function writeSettingsFile(dir, settings) {
|
89
|
+
const llxprtDir = path.join(dir, '.llxprt');
|
90
|
+
await fs.mkdir(llxprtDir, { recursive: true });
|
91
|
+
const settingsPath = path.join(llxprtDir, 'settings.json');
|
92
|
+
await fs.writeFile(settingsPath, JSON.stringify(settings, null, 2), 'utf8');
|
93
|
+
}
|
94
|
+
/**
|
95
|
+
* Waits for a file to exist with timeout
|
96
|
+
* @param filepath - Path to the file to wait for
|
97
|
+
* @param timeout - Maximum time to wait in milliseconds
|
98
|
+
* @returns Promise that resolves when file exists or rejects on timeout
|
99
|
+
*/
|
100
|
+
export async function waitForFile(filepath, timeout) {
|
101
|
+
const startTime = Date.now();
|
102
|
+
const checkInterval = 100; // Check every 100ms
|
103
|
+
while (Date.now() - startTime < timeout) {
|
104
|
+
try {
|
105
|
+
await fs.access(filepath);
|
106
|
+
return; // File exists
|
107
|
+
}
|
108
|
+
catch {
|
109
|
+
// File doesn't exist yet, wait and try again
|
110
|
+
await new Promise((resolve) => setTimeout(resolve, checkInterval));
|
111
|
+
}
|
112
|
+
}
|
113
|
+
throw new Error(`Timeout waiting for file: ${filepath}`);
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
* Creates a simple HTTP server that logs requests
|
117
|
+
* @returns Mock server object with server instance, port, and request log
|
118
|
+
*/
|
119
|
+
export async function createMockApiServer() {
|
120
|
+
const requests = [];
|
121
|
+
const server = http.createServer((req, res) => {
|
122
|
+
let body = '';
|
123
|
+
req.on('data', (chunk) => {
|
124
|
+
body += chunk.toString();
|
125
|
+
});
|
126
|
+
req.on('end', () => {
|
127
|
+
requests.push({
|
128
|
+
method: req.method,
|
129
|
+
url: req.url,
|
130
|
+
headers: req.headers,
|
131
|
+
body,
|
132
|
+
});
|
133
|
+
// Send a simple success response
|
134
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
135
|
+
res.end(JSON.stringify({
|
136
|
+
success: true,
|
137
|
+
message: 'Mock response',
|
138
|
+
}));
|
139
|
+
});
|
140
|
+
});
|
141
|
+
// Find an available port
|
142
|
+
await new Promise((resolve) => {
|
143
|
+
server.listen(0, '127.0.0.1', () => {
|
144
|
+
resolve();
|
145
|
+
});
|
146
|
+
});
|
147
|
+
const address = server.address();
|
148
|
+
if (!address || typeof address === 'string') {
|
149
|
+
throw new Error('Failed to get server port');
|
150
|
+
}
|
151
|
+
return {
|
152
|
+
server,
|
153
|
+
port: address.port,
|
154
|
+
requests,
|
155
|
+
close: () => new Promise((resolve, reject) => {
|
156
|
+
server.close((err) => {
|
157
|
+
if (err) {
|
158
|
+
reject(err);
|
159
|
+
}
|
160
|
+
else {
|
161
|
+
resolve();
|
162
|
+
}
|
163
|
+
});
|
164
|
+
}),
|
165
|
+
};
|
166
|
+
}
|
167
|
+
//# sourceMappingURL=test-utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../../src/integration-tests/test-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,MAAM,MAAM,GAAG,cAAc,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACjE,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,GAAW;IACpD,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,2CAA2C;QAC3C,IACE,KAAK;YACL,OAAO,KAAK,KAAK,QAAQ;YACzB,MAAM,IAAI,KAAK;YACf,KAAK,CAAC,IAAI,KAAK,QAAQ,EACvB,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAW,EACX,IAAY,EACZ,OAAgB;IAEhB,MAAM,WAAW,GAAG,IAAI,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AC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO;QACL,MAAM;QACN,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,QAAQ;QACR,KAAK,EAAE,GAAG,EAAE,CACV,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACpC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACnB,IAAI,GAAG,EAAE,CAAC;oBACR,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,CAAC;qBAAM,CAAC;oBACN,OAAO,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;KACL,CAAC;AACJ,CAAC"}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
* Copyright 2025 Google LLC
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
5
5
|
*/
|
6
|
-
import { executeToolCall, shutdownTelemetry, isTelemetrySdkInitialized, } from '@vybestack/llxprt-code-core';
|
6
|
+
import { executeToolCall, shutdownTelemetry, isTelemetrySdkInitialized, GeminiEventType, ToolErrorType, } from '@vybestack/llxprt-code-core';
|
7
7
|
import { parseAndFormatApiError } from './ui/utils/errorParsing.js';
|
8
8
|
export async function runNonInteractive(config, input, prompt_id) {
|
9
9
|
await config.initialize();
|
@@ -26,78 +26,29 @@ export async function runNonInteractive(config, input, prompt_id) {
|
|
26
26
|
try {
|
27
27
|
while (true) {
|
28
28
|
turnCount++;
|
29
|
-
if (config.getMaxSessionTurns()
|
29
|
+
if (config.getMaxSessionTurns() >= 0 &&
|
30
30
|
turnCount > config.getMaxSessionTurns()) {
|
31
31
|
console.error('\n Reached max session turns for this session. Increase the number of turns by specifying maxSessionTurns in settings.json.');
|
32
32
|
return;
|
33
33
|
}
|
34
34
|
const functionCalls = [];
|
35
|
-
|
36
|
-
let messageToSend;
|
37
|
-
if (process.env.DEBUG) {
|
38
|
-
console.log('DEBUG [nonInteractiveCli]: ===== MESSAGE PROCESSING START =====');
|
39
|
-
console.log('DEBUG [nonInteractiveCli]: Model:', config.getModel());
|
40
|
-
console.log('DEBUG [nonInteractiveCli]: Provider:', config.getProvider());
|
41
|
-
console.log('DEBUG [nonInteractiveCli]: Current messages count:', currentMessages.length);
|
42
|
-
console.log('DEBUG [nonInteractiveCli]: Full currentMessages:', JSON.stringify(currentMessages, null, 2));
|
43
|
-
}
|
44
|
-
if (currentMessages[0]?.parts?.[0]?.functionResponse) {
|
45
|
-
// Send tool response parts directly
|
46
|
-
messageToSend = currentMessages[0].parts;
|
47
|
-
if (process.env.DEBUG) {
|
48
|
-
console.log('DEBUG [nonInteractiveCli]: Message type: TOOL RESPONSE');
|
49
|
-
console.log('DEBUG [nonInteractiveCli]: Sending tool response parts:', JSON.stringify(messageToSend, null, 2));
|
50
|
-
}
|
51
|
-
}
|
52
|
-
else {
|
53
|
-
// Send just the parts array from the first message
|
54
|
-
// This matches what interactive mode does when it sends req (PartListUnion)
|
55
|
-
messageToSend = currentMessages[0]?.parts || [];
|
56
|
-
if (process.env.DEBUG) {
|
57
|
-
console.log('DEBUG [nonInteractiveCli]: Message type: REGULAR MESSAGE');
|
58
|
-
console.log('DEBUG [nonInteractiveCli]: Sending message parts:', JSON.stringify(messageToSend, null, 2));
|
59
|
-
console.log('DEBUG [nonInteractiveCli]: Parts array length:', messageToSend.length);
|
60
|
-
console.log('DEBUG [nonInteractiveCli]: Parts array types:', messageToSend.map((p) => Object.keys(p)));
|
61
|
-
}
|
62
|
-
}
|
63
|
-
if (process.env.DEBUG) {
|
64
|
-
console.log('DEBUG [nonInteractiveCli]: ===== MESSAGE PROCESSING END =====');
|
65
|
-
}
|
66
|
-
if (process.env.DEBUG) {
|
67
|
-
console.log('DEBUG [nonInteractiveCli]: Model being used:', config.getModel());
|
68
|
-
console.log('DEBUG [nonInteractiveCli]: About to call sendMessageStream with messageToSend');
|
69
|
-
}
|
70
|
-
const responseStream = geminiClient.sendMessageStream(messageToSend, abortController.signal, prompt_id);
|
35
|
+
const responseStream = geminiClient.sendMessageStream(currentMessages[0]?.parts || [], abortController.signal, prompt_id);
|
71
36
|
for await (const event of responseStream) {
|
72
37
|
if (abortController.signal.aborted) {
|
73
38
|
console.error('Operation cancelled.');
|
74
39
|
return;
|
75
40
|
}
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
});
|
88
|
-
break;
|
89
|
-
case 'error':
|
90
|
-
console.error('\nError:', event.value.error.message);
|
91
|
-
return;
|
92
|
-
case 'max_session_turns':
|
93
|
-
console.error('\nReached max session turns for this session.');
|
94
|
-
return;
|
95
|
-
case 'loop_detected':
|
96
|
-
console.error('\nLoop detected in conversation.');
|
97
|
-
return;
|
98
|
-
default:
|
99
|
-
// Handle any unexpected event types
|
100
|
-
break;
|
41
|
+
if (event.type === GeminiEventType.Content) {
|
42
|
+
process.stdout.write(event.value);
|
43
|
+
}
|
44
|
+
else if (event.type === GeminiEventType.ToolCallRequest) {
|
45
|
+
const toolCallRequest = event.value;
|
46
|
+
const fc = {
|
47
|
+
name: toolCallRequest.name,
|
48
|
+
args: toolCallRequest.args,
|
49
|
+
id: toolCallRequest.callId,
|
50
|
+
};
|
51
|
+
functionCalls.push(fc);
|
101
52
|
}
|
102
53
|
}
|
103
54
|
if (functionCalls.length > 0) {
|
@@ -113,12 +64,15 @@ export async function runNonInteractive(config, input, prompt_id) {
|
|
113
64
|
};
|
114
65
|
const toolResponse = await executeToolCall(config, requestInfo, toolRegistry, abortController.signal);
|
115
66
|
if (toolResponse.error) {
|
116
|
-
|
117
|
-
|
118
|
-
if (!isToolNotFound) {
|
67
|
+
console.error(`Error executing tool ${fc.name}: ${toolResponse.error.message}`);
|
68
|
+
if (toolResponse.errorType === ToolErrorType.UNHANDLED_EXCEPTION) {
|
119
69
|
process.exit(1);
|
120
70
|
}
|
121
71
|
}
|
72
|
+
// Emit resultDisplay to stdout exactly as produced when available (string only)
|
73
|
+
if (typeof toolResponse.resultDisplay === 'string') {
|
74
|
+
process.stdout.write(toolResponse.resultDisplay);
|
75
|
+
}
|
122
76
|
if (toolResponse.responseParts) {
|
123
77
|
// Handle responseParts as PartListUnion (can be Part, Part[], or string)
|
124
78
|
const parts = toolResponse.responseParts;
|
@@ -147,6 +101,10 @@ export async function runNonInteractive(config, input, prompt_id) {
|
|
147
101
|
}
|
148
102
|
else {
|
149
103
|
process.stdout.write('\n'); // Ensure a final newline
|
104
|
+
// Ensure telemetry is flushed before exiting
|
105
|
+
if (isTelemetrySdkInitialized()) {
|
106
|
+
await shutdownTelemetry();
|
107
|
+
}
|
150
108
|
return;
|
151
109
|
}
|
152
110
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nonInteractiveCli.js","sourceRoot":"","sources":["../../src/nonInteractiveCli.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,eAAe,EAEf,iBAAiB,EACjB,yBAAyB,
|
1
|
+
{"version":3,"file":"nonInteractiveCli.js","sourceRoot":"","sources":["../../src/nonInteractiveCli.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,eAAe,EAEf,iBAAiB,EACjB,yBAAyB,EACzB,eAAe,EACf,aAAa,GACd,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,KAAa,EACb,SAAiB;IAEjB,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAC1B,+EAA+E;IAC/E,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAA0B,EAAE,EAAE;QACxD,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YACzB,yCAAyC;YACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC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C;oBAChC,MAAM,iBAAiB,EAAE,CAAC;gBAC5B,CAAC;gBACD,OAAO;YACT,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,sBAAsB,CACpB,KAAK,EACL,MAAM,CAAC,yBAAyB,EAAE,EAAE,QAAQ,CAC7C,CACF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;YAAS,CAAC;QACT,IAAI,yBAAyB,EAAE,EAAE,CAAC;YAChC,MAAM,iBAAiB,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC;AACH,CAAC"}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2025 Vybestack LLC
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
5
|
+
*/
|
6
|
+
/**
|
7
|
+
* Interface for file system operations to enable dependency injection
|
8
|
+
* and eliminate NODE_ENV checks in production code.
|
9
|
+
*/
|
10
|
+
export interface IFileSystem {
|
11
|
+
/**
|
12
|
+
* Check if a file exists at the given path.
|
13
|
+
*/
|
14
|
+
existsSync(path: string): boolean;
|
15
|
+
/**
|
16
|
+
* Read a file synchronously and return its contents as a string.
|
17
|
+
*/
|
18
|
+
readFileSync(path: string, encoding: BufferEncoding): string;
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* Real file system implementation using Node.js fs module.
|
22
|
+
*/
|
23
|
+
export declare class NodeFileSystem implements IFileSystem {
|
24
|
+
existsSync(path: string): boolean;
|
25
|
+
readFileSync(path: string, encoding: BufferEncoding): string;
|
26
|
+
}
|
27
|
+
/**
|
28
|
+
* Mock file system implementation for testing that doesn't read real files.
|
29
|
+
*/
|
30
|
+
export declare class MockFileSystem implements IFileSystem {
|
31
|
+
private mockFiles;
|
32
|
+
existsSync(path: string): boolean;
|
33
|
+
readFileSync(path: string, _encoding: BufferEncoding): string;
|
34
|
+
/**
|
35
|
+
* Set mock file content for testing.
|
36
|
+
*/
|
37
|
+
setMockFile(path: string, content: string): void;
|
38
|
+
/**
|
39
|
+
* Clear all mock files.
|
40
|
+
*/
|
41
|
+
clearMocks(): void;
|
42
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2025 Vybestack LLC
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
5
|
+
*/
|
6
|
+
import { existsSync as fsExistsSync, readFileSync as fsReadFileSync } from 'fs';
|
7
|
+
/**
|
8
|
+
* Real file system implementation using Node.js fs module.
|
9
|
+
*/
|
10
|
+
export class NodeFileSystem {
|
11
|
+
existsSync(path) {
|
12
|
+
return fsExistsSync(path);
|
13
|
+
}
|
14
|
+
readFileSync(path, encoding) {
|
15
|
+
return fsReadFileSync(path, encoding);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
/**
|
19
|
+
* Mock file system implementation for testing that doesn't read real files.
|
20
|
+
*/
|
21
|
+
export class MockFileSystem {
|
22
|
+
mockFiles = new Map();
|
23
|
+
existsSync(path) {
|
24
|
+
return this.mockFiles.has(path);
|
25
|
+
}
|
26
|
+
readFileSync(path, _encoding) {
|
27
|
+
const content = this.mockFiles.get(path);
|
28
|
+
if (!content) {
|
29
|
+
throw new Error(`ENOENT: no such file or directory, open '${path}'`);
|
30
|
+
}
|
31
|
+
return content;
|
32
|
+
}
|
33
|
+
/**
|
34
|
+
* Set mock file content for testing.
|
35
|
+
*/
|
36
|
+
setMockFile(path, content) {
|
37
|
+
this.mockFiles.set(path, content);
|
38
|
+
}
|
39
|
+
/**
|
40
|
+
* Clear all mock files.
|
41
|
+
*/
|
42
|
+
clearMocks() {
|
43
|
+
this.mockFiles.clear();
|
44
|
+
}
|
45
|
+
}
|
46
|
+
//# sourceMappingURL=IFileSystem.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"IFileSystem.js","sourceRoot":"","sources":["../../../src/providers/IFileSystem.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,YAAY,IAAI,cAAc,EAAE,MAAM,IAAI,CAAC;AAkBhF;;GAEG;AACH,MAAM,OAAO,cAAc;IACzB,UAAU,CAAC,IAAY;QACrB,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,QAAwB;QACjD,OAAO,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,cAAc;IACjB,SAAS,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEnD,UAAU,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,SAAyB;QAClD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,GAAG,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,IAAY,EAAE,OAAe;QACvC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF"}
|
@@ -15,10 +15,6 @@ export interface ProviderConfigResult {
|
|
15
15
|
* Sets or removes the API key for the active provider
|
16
16
|
*/
|
17
17
|
export declare function setProviderApiKey(providerManager: ProviderManager, settings: LoadedSettings, apiKey: string | undefined, config?: Config): Promise<ProviderConfigResult>;
|
18
|
-
/**
|
19
|
-
* Sets the API key from a file for the active provider
|
20
|
-
*/
|
21
|
-
export declare function setProviderApiKeyFromFile(providerManager: ProviderManager, settings: LoadedSettings, filePath: string, config?: Config): Promise<ProviderConfigResult>;
|
22
18
|
/**
|
23
19
|
* Sets or clears the base URL for the active provider
|
24
20
|
*/
|