@blackbox_ai/blackbox-cli-core 0.0.7 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -183
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/src/blackbox/blackboxOAuth2.js +17 -1
- package/dist/src/blackbox/blackboxOAuth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.js +15 -3
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/config/blackboxModels.d.ts +3 -2
- package/dist/src/config/blackboxModels.js +262 -33
- package/dist/src/config/blackboxModels.js.map +1 -1
- package/dist/src/config/config.d.ts +65 -0
- package/dist/src/config/config.js +282 -17
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/models.d.ts +1 -1
- package/dist/src/config/models.js +1 -1
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/multiAgentModels.d.ts +63 -0
- package/dist/src/config/multiAgentModels.js +194 -0
- package/dist/src/config/multiAgentModels.js.map +1 -0
- package/dist/src/core/client.js +11 -5
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +1 -0
- package/dist/src/core/contentGenerator.js +57 -7
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/coreToolScheduler.js +2 -2
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/encryptedClientFactory.d.ts +17 -0
- package/dist/src/core/encryptedClientFactory.js +92 -0
- package/dist/src/core/encryptedClientFactory.js.map +1 -0
- package/dist/src/core/encryptedContentGenerator.d.ts +47 -0
- package/dist/src/core/encryptedContentGenerator.js +445 -0
- package/dist/src/core/encryptedContentGenerator.js.map +1 -0
- package/dist/src/core/encryptedGeminiClient.d.ts +59 -0
- package/dist/src/core/encryptedGeminiClient.js +177 -0
- package/dist/src/core/encryptedGeminiClient.js.map +1 -0
- package/dist/src/core/encryptedGeminiClientBridge.d.ts +107 -0
- package/dist/src/core/encryptedGeminiClientBridge.js +808 -0
- package/dist/src/core/encryptedGeminiClientBridge.js.map +1 -0
- package/dist/src/core/encryptedGeminiClientWrapper.d.ts +129 -0
- package/dist/src/core/encryptedGeminiClientWrapper.js +305 -0
- package/dist/src/core/encryptedGeminiClientWrapper.js.map +1 -0
- package/dist/src/core/encryptedTurn.d.ts +40 -0
- package/dist/src/core/encryptedTurn.js +114 -0
- package/dist/src/core/encryptedTurn.js.map +1 -0
- package/dist/src/core/logger.d.ts +21 -0
- package/dist/src/core/logger.js +110 -0
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/openaiContentGenerator/constants.d.ts +2 -0
- package/dist/src/core/openaiContentGenerator/constants.js +2 -0
- package/dist/src/core/openaiContentGenerator/constants.js.map +1 -1
- package/dist/src/core/openaiContentGenerator/converter.d.ts +16 -1
- package/dist/src/core/openaiContentGenerator/converter.js +135 -4
- package/dist/src/core/openaiContentGenerator/converter.js.map +1 -1
- package/dist/src/core/openaiContentGenerator/pipeline.js +22 -8
- package/dist/src/core/openaiContentGenerator/pipeline.js.map +1 -1
- package/dist/src/core/openaiContentGenerator/pipeline.test.js +51 -0
- package/dist/src/core/openaiContentGenerator/pipeline.test.js.map +1 -1
- package/dist/src/core/openaiContentGenerator/provider/default.js +10 -1
- package/dist/src/core/openaiContentGenerator/provider/default.js.map +1 -1
- package/dist/src/core/prompts.d.ts +18 -1
- package/dist/src/core/prompts.js +388 -459
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/tokenLimits.d.ts +1 -0
- package/dist/src/core/tokenLimits.js +37 -2
- package/dist/src/core/tokenLimits.js.map +1 -1
- package/dist/src/core/tokenLimits.test.js +36 -1
- package/dist/src/core/tokenLimits.test.js.map +1 -1
- package/dist/src/encrypt/attestation.d.ts +5 -0
- package/dist/src/encrypt/attestation.js +100 -0
- package/dist/src/encrypt/attestation.js.map +1 -0
- package/dist/src/encrypt/client.d.ts +14 -0
- package/dist/src/encrypt/client.js +132 -0
- package/dist/src/encrypt/client.js.map +1 -0
- package/dist/src/encrypt/config.d.ts +22 -0
- package/dist/src/encrypt/config.js +43 -0
- package/dist/src/encrypt/config.js.map +1 -0
- package/dist/src/encrypt/crypto-utils.d.ts +57 -0
- package/dist/src/encrypt/crypto-utils.js +257 -0
- package/dist/src/encrypt/crypto-utils.js.map +1 -0
- package/dist/src/encrypt/history-manager.d.ts +43 -0
- package/dist/src/encrypt/history-manager.js +164 -0
- package/dist/src/encrypt/history-manager.js.map +1 -0
- package/dist/src/encrypt/minimax-template.d.ts +73 -0
- package/dist/src/encrypt/minimax-template.js +276 -0
- package/dist/src/encrypt/minimax-template.js.map +1 -0
- package/dist/src/encrypt/sessions.d.ts +17 -0
- package/dist/src/encrypt/sessions.js +221 -0
- package/dist/src/encrypt/sessions.js.map +1 -0
- package/dist/src/encrypt/streaming-client.d.ts +29 -0
- package/dist/src/encrypt/streaming-client.js +232 -0
- package/dist/src/encrypt/streaming-client.js.map +1 -0
- package/dist/src/encrypt/tool-formatter.d.ts +36 -0
- package/dist/src/encrypt/tool-formatter.js +353 -0
- package/dist/src/encrypt/tool-formatter.js.map +1 -0
- package/dist/src/encrypt/tool-parser.d.ts +93 -0
- package/dist/src/encrypt/tool-parser.js +567 -0
- package/dist/src/encrypt/tool-parser.js.map +1 -0
- package/dist/src/encrypt/types.d.ts +81 -0
- package/dist/src/encrypt/types.js +2 -0
- package/dist/src/encrypt/types.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +3 -3
- package/dist/src/generated/git-commit.js +3 -3
- package/dist/src/ide/ide-client.js +9 -19
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.js +15 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/oauth-provider.js +2 -6
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.d.ts +7 -0
- package/dist/src/mcp/oauth-token-storage.js +24 -0
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/services/EncryptedChatService.d.ts +80 -0
- package/dist/src/services/EncryptedChatService.js +202 -0
- package/dist/src/services/EncryptedChatService.js.map +1 -0
- package/dist/src/services/StatsHistoryService.d.ts +131 -0
- package/dist/src/services/StatsHistoryService.js +427 -0
- package/dist/src/services/StatsHistoryService.js.map +1 -0
- package/dist/src/services/checkpointApiService.d.ts +101 -0
- package/dist/src/services/checkpointApiService.js +215 -0
- package/dist/src/services/checkpointApiService.js.map +1 -0
- package/dist/src/services/environmentSanitization.d.ts +24 -0
- package/dist/src/services/environmentSanitization.js +152 -0
- package/dist/src/services/environmentSanitization.js.map +1 -0
- package/dist/src/telemetry/blackbox-logger/blackbox-logger.d.ts +2 -6
- package/dist/src/telemetry/blackbox-logger/blackbox-logger.js +29 -135
- package/dist/src/telemetry/blackbox-logger/blackbox-logger.js.map +1 -1
- package/dist/src/telemetry/blackbox-logger/blackbox-logger.test.js +1 -1
- package/dist/src/telemetry/blackbox-logger/blackbox-logger.test.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +8 -0
- package/dist/src/telemetry/uiTelemetry.js +17 -0
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/tools/browser-interactive.d.ts +63 -0
- package/dist/src/tools/browser-interactive.js +394 -0
- package/dist/src/tools/browser-interactive.js.map +1 -0
- package/dist/src/tools/browser_use.d.ts +23 -2
- package/dist/src/tools/browser_use.js +424 -43
- package/dist/src/tools/browser_use.js.map +1 -1
- package/dist/src/tools/data-file-constants.d.ts +17 -0
- package/dist/src/tools/data-file-constants.js +30 -0
- package/dist/src/tools/data-file-constants.js.map +1 -0
- package/dist/src/tools/edit.js +44 -7
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/exitPlanMode.js +1 -1
- package/dist/src/tools/exitPlanMode.js.map +1 -1
- package/dist/src/tools/ls.js +40 -6
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +4 -4
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +28 -2
- package/dist/src/tools/mcp-client-manager.js +62 -4
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +5 -3
- package/dist/src/tools/mcp-client.js +39 -11
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +3 -1
- package/dist/src/tools/mcp-tool.js +37 -9
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +14 -4
- package/dist/src/tools/memoryTool.js +98 -39
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/read-data-file.d.ts +31 -0
- package/dist/src/tools/read-data-file.js +469 -0
- package/dist/src/tools/read-data-file.js.map +1 -0
- package/dist/src/tools/read-file.js +64 -5
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +40 -6
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/shell.d.ts +3 -1
- package/dist/src/tools/shell.js +25 -4
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/skill.d.ts +34 -0
- package/dist/src/tools/skill.js +143 -0
- package/dist/src/tools/skill.js.map +1 -0
- package/dist/src/tools/sql_db.d.ts +101 -0
- package/dist/src/tools/sql_db.js +1033 -0
- package/dist/src/tools/sql_db.js.map +1 -0
- package/dist/src/tools/sql_db_configure.d.ts +18 -0
- package/dist/src/tools/sql_db_configure.js +96 -0
- package/dist/src/tools/sql_db_configure.js.map +1 -0
- package/dist/src/tools/taskCompletion.d.ts +29 -0
- package/dist/src/tools/taskCompletion.js +231 -0
- package/dist/src/tools/taskCompletion.js.map +1 -0
- package/dist/src/tools/todoWrite.js +0 -142
- package/dist/src/tools/todoWrite.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +3 -1
- package/dist/src/tools/tool-error.js +3 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +8 -0
- package/dist/src/tools/tool-names.js +8 -0
- package/dist/src/tools/tool-names.js.map +1 -1
- package/dist/src/tools/tool-registry.d.ts +22 -0
- package/dist/src/tools/tool-registry.js +41 -1
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tools.d.ts +18 -2
- package/dist/src/tools/tools.js +3 -0
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/web-fetch.js +24 -4
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-search.js +160 -2
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/workspace-error-helper.d.ts +9 -0
- package/dist/src/tools/workspace-error-helper.js +43 -0
- package/dist/src/tools/workspace-error-helper.js.map +1 -0
- package/dist/src/tools/workspace-error-helper.test.js +85 -0
- package/dist/src/tools/workspace-error-helper.test.js.map +1 -0
- package/dist/src/tools/write-file.js +42 -7
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/utils/environmentContext.js +3 -1
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +3 -2
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/fetch.d.ts +3 -1
- package/dist/src/utils/fetch.js +35 -2
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.js +30 -3
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.d.ts +2 -0
- package/dist/src/utils/filesearch/fileSearch.js +38 -7
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/git-worktree-utils.d.ts +56 -0
- package/dist/src/utils/git-worktree-utils.js +176 -0
- package/dist/src/utils/git-worktree-utils.js.map +1 -0
- package/dist/src/utils/imageCompression.d.ts +34 -0
- package/dist/src/utils/imageCompression.js +170 -0
- package/dist/src/utils/imageCompression.js.map +1 -0
- package/dist/src/utils/messageTruncator.d.ts +51 -0
- package/dist/src/utils/messageTruncator.js +346 -0
- package/dist/src/utils/messageTruncator.js.map +1 -0
- package/dist/src/utils/pathReader.js +26 -6
- package/dist/src/utils/pathReader.js.map +1 -1
- package/dist/src/utils/skill.d.ts +65 -0
- package/dist/src/utils/skill.js +241 -0
- package/dist/src/utils/skill.js.map +1 -0
- package/dist/src/utils/textCleaning.d.ts +51 -0
- package/dist/src/utils/textCleaning.js +327 -0
- package/dist/src/utils/textCleaning.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -6
- package/dist/src/tools/mcp-client-manager.test.js +0 -39
- package/dist/src/tools/mcp-client-manager.test.js.map +0 -1
- package/dist/src/tools/mcp-client.test.d.ts +0 -6
- package/dist/src/tools/mcp-client.test.js +0 -454
- package/dist/src/tools/mcp-client.test.js.map +0 -1
- package/dist/src/tools/mcp-tool.test.d.ts +0 -6
- package/dist/src/tools/mcp-tool.test.js +0 -576
- package/dist/src/tools/mcp-tool.test.js.map +0 -1
- package/dist/src/tools/memoryTool.test.d.ts +0 -6
- package/dist/src/tools/memoryTool.test.js +0 -420
- package/dist/src/tools/memoryTool.test.js.map +0 -1
- package/dist/src/tools/tool-registry.test.d.ts +0 -6
- package/dist/src/tools/tool-registry.test.js +0 -332
- package/dist/src/tools/tool-registry.test.js.map +0 -1
- /package/dist/src/tools/{mcp-client-manager.test.d.ts → workspace-error-helper.test.d.ts} +0 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export class CheckpointApiService {
|
|
7
|
+
apiBaseUrl;
|
|
8
|
+
apiKey;
|
|
9
|
+
constructor(apiKey) {
|
|
10
|
+
// Use environment variable or provided API key
|
|
11
|
+
this.apiKey = apiKey || process.env['BLACKBOX_API_KEY'];
|
|
12
|
+
// API base URL - can be overridden with environment variable
|
|
13
|
+
this.apiBaseUrl = process.env['BLACKBOX_API_URL'] || 'https://cloud.blackbox.ai';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if the service is configured with a valid API key
|
|
17
|
+
*/
|
|
18
|
+
isConfigured() {
|
|
19
|
+
return !!this.apiKey;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Normalize checkpoint tag to API format
|
|
23
|
+
* Supports:
|
|
24
|
+
* - "cloud-task-<taskId>" -> returns as-is
|
|
25
|
+
* - "<taskId>" -> converts to "cloud-task-<taskId>"
|
|
26
|
+
*
|
|
27
|
+
* @param tag - The checkpoint tag
|
|
28
|
+
* @returns Normalized tag in "cloud-task-<taskId>" format
|
|
29
|
+
*/
|
|
30
|
+
normalizeTag(tag) {
|
|
31
|
+
// If already in correct format, return as-is
|
|
32
|
+
if (tag.startsWith('cloud-task-')) {
|
|
33
|
+
return tag;
|
|
34
|
+
}
|
|
35
|
+
// If starts with just "cloud-", assume it's "cloud-<taskId>" and convert
|
|
36
|
+
if (tag.startsWith('cloud-')) {
|
|
37
|
+
const taskId = tag.substring(6); // Remove "cloud-" prefix
|
|
38
|
+
return `cloud-task-${taskId}`;
|
|
39
|
+
}
|
|
40
|
+
// Otherwise, assume it's just the taskId and prepend "cloud-task-"
|
|
41
|
+
return `cloud-task-${tag}`;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* List all tasks with checkpoints for the authenticated user
|
|
45
|
+
* @param filters - Optional filters (status, limit, offset)
|
|
46
|
+
* @returns List of tasks with checkpoint summaries
|
|
47
|
+
*/
|
|
48
|
+
async listTasks(filters) {
|
|
49
|
+
if (!this.apiKey) {
|
|
50
|
+
throw new Error('Blackbox API key not configured. Please set BLACKBOX_API_KEY environment variable.');
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const url = `${this.apiBaseUrl}/api/public/checkpoint`;
|
|
54
|
+
const response = await fetch(url, {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
headers: {
|
|
57
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
58
|
+
'Content-Type': 'application/json',
|
|
59
|
+
},
|
|
60
|
+
body: JSON.stringify(filters || {}),
|
|
61
|
+
});
|
|
62
|
+
if (!response.ok) {
|
|
63
|
+
if (response.status === 401) {
|
|
64
|
+
throw new Error('Invalid Blackbox API key. Please check your BLACKBOX_API_KEY.');
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const errorText = await response.text();
|
|
68
|
+
throw new Error(`API request failed (${response.status}): ${errorText}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const data = await response.json();
|
|
72
|
+
if (!data.success || !data.tasks) {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
return data.tasks;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if (error instanceof Error) {
|
|
79
|
+
// Re-throw known errors
|
|
80
|
+
if (error.message.includes('API key') || error.message.includes('API request failed')) {
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
// Wrap network errors
|
|
84
|
+
throw new Error(`Failed to fetch tasks from API: ${error.message}`);
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Fetch checkpoint data from the public API
|
|
91
|
+
* @param tag - The checkpoint tag (e.g., "cloud-task-abc123" or just "abc123")
|
|
92
|
+
* @returns Checkpoint data or null if not found
|
|
93
|
+
*/
|
|
94
|
+
async fetchCheckpointByTag(tag) {
|
|
95
|
+
if (!this.apiKey) {
|
|
96
|
+
throw new Error('Blackbox API key not configured. Please set BLACKBOX_API_KEY environment variable.');
|
|
97
|
+
}
|
|
98
|
+
// Normalize the tag to the format expected by the API
|
|
99
|
+
const normalizedTag = this.normalizeTag(tag);
|
|
100
|
+
try {
|
|
101
|
+
const url = `${this.apiBaseUrl}/api/public/checkpoint?taskId=${encodeURIComponent(normalizedTag)}`;
|
|
102
|
+
const response = await fetch(url, {
|
|
103
|
+
method: 'GET',
|
|
104
|
+
headers: {
|
|
105
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
106
|
+
'Content-Type': 'application/json',
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
if (response.status === 401) {
|
|
111
|
+
throw new Error('Invalid Blackbox API key. Please check your BLACKBOX_API_KEY.');
|
|
112
|
+
}
|
|
113
|
+
else if (response.status === 404) {
|
|
114
|
+
return null; // Checkpoint not found
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const errorText = await response.text();
|
|
118
|
+
throw new Error(`API request failed (${response.status}): ${errorText}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const data = await response.json();
|
|
122
|
+
if (!data.success || !data.checkpoint) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
return data.checkpoint;
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
if (error instanceof Error) {
|
|
129
|
+
// Re-throw known errors
|
|
130
|
+
if (error.message.includes('API key') || error.message.includes('API request failed')) {
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
// Wrap network errors
|
|
134
|
+
throw new Error(`Failed to fetch checkpoint from API: ${error.message}`);
|
|
135
|
+
}
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Fetch task info by ID (without checkpoint content)
|
|
141
|
+
* @param taskId - The task ID (e.g., "abc123" or "cloud-task-abc123")
|
|
142
|
+
* @returns Task summary or null if not found
|
|
143
|
+
*/
|
|
144
|
+
async fetchTaskById(taskId) {
|
|
145
|
+
if (!this.apiKey) {
|
|
146
|
+
throw new Error('Blackbox API key not configured. Please set BLACKBOX_API_KEY environment variable.');
|
|
147
|
+
}
|
|
148
|
+
// Normalize the tag to the format expected by the API
|
|
149
|
+
const normalizedTag = this.normalizeTag(taskId);
|
|
150
|
+
try {
|
|
151
|
+
const url = `${this.apiBaseUrl}/api/public/checkpoint?taskId=${encodeURIComponent(normalizedTag)}`;
|
|
152
|
+
const response = await fetch(url, {
|
|
153
|
+
method: 'GET',
|
|
154
|
+
headers: {
|
|
155
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
156
|
+
'Content-Type': 'application/json',
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
if (!response.ok) {
|
|
160
|
+
if (response.status === 401) {
|
|
161
|
+
throw new Error('Invalid Blackbox API key. Please check your BLACKBOX_API_KEY.');
|
|
162
|
+
}
|
|
163
|
+
else if (response.status === 404) {
|
|
164
|
+
return null; // Task not found
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const errorText = await response.text();
|
|
168
|
+
throw new Error(`API request failed (${response.status}): ${errorText}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const data = await response.json();
|
|
172
|
+
if (!data.success || !data.task) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
return data.task;
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
if (error instanceof Error) {
|
|
179
|
+
// Re-throw known errors
|
|
180
|
+
if (error.message.includes('API key') || error.message.includes('API request failed')) {
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
// Wrap network errors
|
|
184
|
+
throw new Error(`Failed to fetch task from API: ${error.message}`);
|
|
185
|
+
}
|
|
186
|
+
throw error;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Test the API connection and authentication
|
|
191
|
+
* @returns true if connection is successful, false otherwise
|
|
192
|
+
*/
|
|
193
|
+
async testConnection() {
|
|
194
|
+
if (!this.apiKey) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
// Try to fetch a non-existent checkpoint to test auth
|
|
199
|
+
const url = `${this.apiBaseUrl}/api/public/checkpoint?taskId=cloud-task-test`;
|
|
200
|
+
const response = await fetch(url, {
|
|
201
|
+
method: 'GET',
|
|
202
|
+
headers: {
|
|
203
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
204
|
+
'Content-Type': 'application/json',
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
// 401 means auth failed, 404 means auth worked but checkpoint not found
|
|
208
|
+
return response.status !== 401;
|
|
209
|
+
}
|
|
210
|
+
catch (_error) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=checkpointApiService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpointApiService.js","sourceRoot":"","sources":["../../../src/services/checkpointApiService.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAyDH,MAAM,OAAO,oBAAoB;IACd,UAAU,CAAS;IACnB,MAAM,CAAqB;IAE5C,YAAY,MAAe;QACzB,+CAA+C;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAExD,6DAA6D;QAC7D,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,2BAA2B,CAAC;IACnF,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;;OAQG;IACK,YAAY,CAAC,GAAW;QAC9B,6CAA6C;QAC7C,IAAI,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;YAClC,OAAO,GAAG,CAAC;QACb,CAAC;QAED,yEAAyE;QACzE,IAAI,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,yBAAyB;YAC1D,OAAO,cAAc,MAAM,EAAE,CAAC;QAChC,CAAC;QAED,mEAAmE;QACnE,OAAO,c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AAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC;YACH,sDAAsD;YACtD,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,UAAU,+CAA+C,CAAC;YAE9E,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAChC,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE;oBACP,eAAe,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;oBACxC,cAAc,EAAE,kBAAkB;iBACnC;aACF,CAAC,CAAC;YAEH,wEAAwE;YACxE,OAAO,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC;QACjC,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export type EnvironmentSanitizationConfig = {
|
|
7
|
+
allowedEnvironmentVariables: string[];
|
|
8
|
+
blockedEnvironmentVariables: string[];
|
|
9
|
+
enableEnvironmentVariableRedaction: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Interpolates environment variable references in a string.
|
|
13
|
+
* Supports ${VAR_NAME} syntax.
|
|
14
|
+
*
|
|
15
|
+
* @param value The string that may contain ${VAR_NAME} references
|
|
16
|
+
* @param env The environment to use for interpolation
|
|
17
|
+
* @returns The string with variables interpolated
|
|
18
|
+
*/
|
|
19
|
+
export declare function interpolateEnvVars(value: string, env: NodeJS.ProcessEnv): string;
|
|
20
|
+
export declare function sanitizeEnvironment(processEnv: NodeJS.ProcessEnv, config: EnvironmentSanitizationConfig): NodeJS.ProcessEnv;
|
|
21
|
+
export declare const ALWAYS_ALLOWED_ENVIRONMENT_VARIABLES: ReadonlySet<string>;
|
|
22
|
+
export declare const NEVER_ALLOWED_ENVIRONMENT_VARIABLES: ReadonlySet<string>;
|
|
23
|
+
export declare const NEVER_ALLOWED_NAME_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
24
|
+
export declare const NEVER_ALLOWED_VALUE_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Interpolates environment variable references in a string.
|
|
8
|
+
* Supports ${VAR_NAME} syntax.
|
|
9
|
+
*
|
|
10
|
+
* @param value The string that may contain ${VAR_NAME} references
|
|
11
|
+
* @param env The environment to use for interpolation
|
|
12
|
+
* @returns The string with variables interpolated
|
|
13
|
+
*/
|
|
14
|
+
export function interpolateEnvVars(value, env) {
|
|
15
|
+
return value.replace(/\$\{([^}]+)\}/g, (_, varName) => env[varName] ?? `\${${varName}}`);
|
|
16
|
+
}
|
|
17
|
+
export function sanitizeEnvironment(processEnv, config) {
|
|
18
|
+
if (!config.enableEnvironmentVariableRedaction) {
|
|
19
|
+
return { ...processEnv };
|
|
20
|
+
}
|
|
21
|
+
const results = {};
|
|
22
|
+
const allowedSet = new Set((config.allowedEnvironmentVariables || []).map((k) => k.toUpperCase()));
|
|
23
|
+
const blockedSet = new Set((config.blockedEnvironmentVariables || []).map((k) => k.toUpperCase()));
|
|
24
|
+
// Enable strict sanitization in GitHub actions.
|
|
25
|
+
const isStrictSanitization = !!processEnv['GITHUB_SHA'];
|
|
26
|
+
for (const key in processEnv) {
|
|
27
|
+
const value = processEnv[key];
|
|
28
|
+
if (!shouldRedactEnvironmentVariable(key, value, allowedSet, blockedSet, isStrictSanitization)) {
|
|
29
|
+
results[key] = value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return results;
|
|
33
|
+
}
|
|
34
|
+
export const ALWAYS_ALLOWED_ENVIRONMENT_VARIABLES = new Set([
|
|
35
|
+
// Cross-platform
|
|
36
|
+
'PATH',
|
|
37
|
+
// Windows specific
|
|
38
|
+
'SYSTEMROOT',
|
|
39
|
+
'COMSPEC',
|
|
40
|
+
'PATHEXT',
|
|
41
|
+
'WINDIR',
|
|
42
|
+
'TEMP',
|
|
43
|
+
'TMP',
|
|
44
|
+
'USERPROFILE',
|
|
45
|
+
'SYSTEMDRIVE',
|
|
46
|
+
// Unix/Linux/macOS specific
|
|
47
|
+
'HOME',
|
|
48
|
+
'LANG',
|
|
49
|
+
'SHELL',
|
|
50
|
+
'TMPDIR',
|
|
51
|
+
'USER',
|
|
52
|
+
'LOGNAME',
|
|
53
|
+
// GitHub Action-related variables
|
|
54
|
+
'ADDITIONAL_CONTEXT',
|
|
55
|
+
'AVAILABLE_LABELS',
|
|
56
|
+
'BRANCH_NAME',
|
|
57
|
+
'DESCRIPTION',
|
|
58
|
+
'EVENT_NAME',
|
|
59
|
+
'GITHUB_ENV',
|
|
60
|
+
'IS_PULL_REQUEST',
|
|
61
|
+
'ISSUES_TO_TRIAGE',
|
|
62
|
+
'ISSUE_BODY',
|
|
63
|
+
'ISSUE_NUMBER',
|
|
64
|
+
'ISSUE_TITLE',
|
|
65
|
+
'PULL_REQUEST_NUMBER',
|
|
66
|
+
'REPOSITORY',
|
|
67
|
+
'TITLE',
|
|
68
|
+
'TRIGGERING_ACTOR',
|
|
69
|
+
]);
|
|
70
|
+
export const NEVER_ALLOWED_ENVIRONMENT_VARIABLES = new Set([
|
|
71
|
+
'CLIENT_ID',
|
|
72
|
+
'DB_URI',
|
|
73
|
+
'CONNECTION_STRING',
|
|
74
|
+
'AWS_DEFAULT_REGION',
|
|
75
|
+
'AZURE_CLIENT_ID',
|
|
76
|
+
'AZURE_TENANT_ID',
|
|
77
|
+
'SLACK_WEBHOOK_URL',
|
|
78
|
+
'TWILIO_ACCOUNT_SID',
|
|
79
|
+
'DATABASE_URL',
|
|
80
|
+
'GOOGLE_CLOUD_PROJECT',
|
|
81
|
+
'GOOGLE_CLOUD_ACCOUNT',
|
|
82
|
+
'FIREBASE_PROJECT_ID',
|
|
83
|
+
]);
|
|
84
|
+
export const NEVER_ALLOWED_NAME_PATTERNS = [
|
|
85
|
+
/TOKEN/i,
|
|
86
|
+
/SECRET/i,
|
|
87
|
+
/PASSWORD/i,
|
|
88
|
+
/PASSWD/i,
|
|
89
|
+
/KEY/i,
|
|
90
|
+
/AUTH/i,
|
|
91
|
+
/CREDENTIAL/i,
|
|
92
|
+
/CREDS/i,
|
|
93
|
+
/PRIVATE/i,
|
|
94
|
+
/CERT/i,
|
|
95
|
+
];
|
|
96
|
+
export const NEVER_ALLOWED_VALUE_PATTERNS = [
|
|
97
|
+
/-----BEGIN (RSA|OPENSSH|EC|PGP) PRIVATE KEY-----/i,
|
|
98
|
+
/-----BEGIN CERTIFICATE-----/i,
|
|
99
|
+
// Credentials in URL
|
|
100
|
+
/(https?|ftp|smtp):\/\/[^:]+:[^@]+@/i,
|
|
101
|
+
// GitHub tokens (classic, fine-grained, OAuth, etc.)
|
|
102
|
+
/(ghp|gho|ghu|ghs|ghr|github_pat)_[a-zA-Z0-9_]{36,}/i,
|
|
103
|
+
// Google API keys
|
|
104
|
+
/AIzaSy[a-zA-Z0-9_\\-]{33}/i,
|
|
105
|
+
// Amazon AWS Access Key ID
|
|
106
|
+
/AKIA[A-Z0-9]{16}/i,
|
|
107
|
+
// Generic OAuth/JWT tokens
|
|
108
|
+
/eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*/i,
|
|
109
|
+
// Stripe API keys
|
|
110
|
+
/(s|r)k_(live|test)_[0-9a-zA-Z]{24}/i,
|
|
111
|
+
// Slack tokens (bot, user, etc.)
|
|
112
|
+
/xox[abpr]-[a-zA-Z0-9-]+/i,
|
|
113
|
+
];
|
|
114
|
+
function shouldRedactEnvironmentVariable(key, value, allowedSet, blockedSet, isStrictSanitization = false) {
|
|
115
|
+
key = key.toUpperCase();
|
|
116
|
+
value = value?.toUpperCase();
|
|
117
|
+
// User overrides take precedence.
|
|
118
|
+
if (allowedSet?.has(key)) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
if (blockedSet?.has(key)) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
// These are never redacted.
|
|
125
|
+
if (ALWAYS_ALLOWED_ENVIRONMENT_VARIABLES.has(key) ||
|
|
126
|
+
key.startsWith('GEMINI_CLI_')) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
// These are always redacted.
|
|
130
|
+
if (NEVER_ALLOWED_ENVIRONMENT_VARIABLES.has(key)) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
// If in strict mode (e.g. GitHub Action), and not explicitly allowed, redact it.
|
|
134
|
+
if (isStrictSanitization) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
for (const pattern of NEVER_ALLOWED_NAME_PATTERNS) {
|
|
138
|
+
if (pattern.test(key)) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Redact if the value looks like a key/cert.
|
|
143
|
+
if (value) {
|
|
144
|
+
for (const pattern of NEVER_ALLOWED_VALUE_PATTERNS) {
|
|
145
|
+
if (pattern.test(value)) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=environmentSanitization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environmentSanitization.js","sourceRoot":"","sources":["../../../src/services/environmentSanitization.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAa,EACb,GAAsB;IAEtB,OAAO,KAAK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E7B,kCAAkC;IAClC,IAAI,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,4BAA4B;IAC5B,IACE,oCAAoC,CAAC,GAAG,CAAC,GAAG,CAAC;QAC7C,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,EAC7B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6BAA6B;IAC7B,IAAI,mCAAmC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iFAAiF;IACjF,IAAI,oBAAoB,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,2BAA2B,EAAE,CAAC;QAClD,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,6CAA6C;IAC7C,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,MAAM,OAAO,IAAI,4BAA4B,EAAE,CAAC;YACnD,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBACxB,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
7
6
|
import type { StartSessionEvent, UserPromptEvent, ToolCallEvent, ApiRequestEvent, ApiResponseEvent, ApiErrorEvent, FileOperationEvent, FlashFallbackEvent, LoopDetectedEvent, NextSpeakerCheckEvent, SlashCommandEvent, MalformedJsonResponseEvent, IdeConnectionEvent, KittySequenceOverflowEvent, ChatCompressionEvent, InvalidChunkEvent, ContentRetryEvent, ContentRetryFailureEvent, ConversationFinishedEvent, SubagentExecutionEvent } from '../types.js';
|
|
8
7
|
import { EndSessionEvent } from '../types.js';
|
|
9
8
|
import type { RumEvent, RumViewEvent, RumActionEvent, RumResourceEvent, RumExceptionEvent, RumPayload } from './event-types.js';
|
|
@@ -16,12 +15,11 @@ export declare class BlackboxLogger {
|
|
|
16
15
|
private config?;
|
|
17
16
|
private readonly installationManager;
|
|
18
17
|
/**
|
|
19
|
-
* Queue of pending events that
|
|
20
|
-
* are added to this queue and then flushed on demand (via `flushToRum`)
|
|
18
|
+
* Queue of pending events that are stored in memory.
|
|
21
19
|
*/
|
|
22
20
|
private readonly events;
|
|
23
21
|
/**
|
|
24
|
-
* The last time that the events were
|
|
22
|
+
* The last time that the events were cleared from memory.
|
|
25
23
|
*/
|
|
26
24
|
private lastFlushTime;
|
|
27
25
|
private userId;
|
|
@@ -69,9 +67,7 @@ export declare class BlackboxLogger {
|
|
|
69
67
|
logContentRetryFailureEvent(event: ContentRetryFailureEvent): void;
|
|
70
68
|
logSubagentExecutionEvent(event: SubagentExecutionEvent): void;
|
|
71
69
|
logEndSessionEvent(_event: EndSessionEvent): void;
|
|
72
|
-
getProxyAgent(): HttpsProxyAgent<string> | undefined;
|
|
73
70
|
shutdown(): void;
|
|
74
|
-
private requeueFailedEvents;
|
|
75
71
|
}
|
|
76
72
|
export declare const TEST_ONLY: {
|
|
77
73
|
MAX_RETRY_EVENTS: number;
|