@probelabs/probe 0.6.0-rc100
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 +583 -0
- package/bin/.gitkeep +0 -0
- package/bin/probe +158 -0
- package/bin/probe-binary +0 -0
- package/build/agent/ProbeAgent.d.ts +199 -0
- package/build/agent/ProbeAgent.js +1486 -0
- package/build/agent/acp/README.md +347 -0
- package/build/agent/acp/connection.js +237 -0
- package/build/agent/acp/connection.test.js +311 -0
- package/build/agent/acp/examples/simple-client.js +212 -0
- package/build/agent/acp/examples/tool-lifecycle.js +230 -0
- package/build/agent/acp/final-test.js +173 -0
- package/build/agent/acp/index.js +5 -0
- package/build/agent/acp/integration.test.js +385 -0
- package/build/agent/acp/manual-test.js +410 -0
- package/build/agent/acp/protocol-test.js +190 -0
- package/build/agent/acp/server.js +448 -0
- package/build/agent/acp/server.test.js +371 -0
- package/build/agent/acp/test-runner.js +216 -0
- package/build/agent/acp/test-utils/README.md +315 -0
- package/build/agent/acp/test-utils/acp-tester.js +484 -0
- package/build/agent/acp/test-utils/mock-acp-client.js +434 -0
- package/build/agent/acp/tools.js +368 -0
- package/build/agent/acp/tools.test.js +334 -0
- package/build/agent/acp/types.js +218 -0
- package/build/agent/acp/types.test.js +327 -0
- package/build/agent/appTracer.js +360 -0
- package/build/agent/fileSpanExporter.js +169 -0
- package/build/agent/index.js +7426 -0
- package/build/agent/mcp/client.js +338 -0
- package/build/agent/mcp/config.js +313 -0
- package/build/agent/mcp/index.js +64 -0
- package/build/agent/mcp/xmlBridge.js +371 -0
- package/build/agent/mockProvider.js +53 -0
- package/build/agent/probeTool.js +257 -0
- package/build/agent/schemaUtils.js +1726 -0
- package/build/agent/simpleTelemetry.js +267 -0
- package/build/agent/telemetry.js +225 -0
- package/build/agent/tokenCounter.js +395 -0
- package/build/agent/tools.js +163 -0
- package/build/cli.js +49 -0
- package/build/delegate.js +267 -0
- package/build/directory-resolver.js +237 -0
- package/build/downloader.js +750 -0
- package/build/extract.js +149 -0
- package/build/index.js +70 -0
- package/build/mcp/index.js +514 -0
- package/build/mcp/index.ts +608 -0
- package/build/query.js +116 -0
- package/build/search.js +247 -0
- package/build/tools/common.js +410 -0
- package/build/tools/index.js +40 -0
- package/build/tools/langchain.js +88 -0
- package/build/tools/system-message.js +121 -0
- package/build/tools/vercel.js +271 -0
- package/build/utils/file-lister.js +193 -0
- package/build/utils.js +128 -0
- package/cjs/agent/ProbeAgent.cjs +5829 -0
- package/cjs/index.cjs +6217 -0
- package/cjs/package.json +3 -0
- package/index.d.ts +401 -0
- package/package.json +114 -0
- package/scripts/postinstall.js +172 -0
- package/src/agent/ProbeAgent.d.ts +199 -0
- package/src/agent/ProbeAgent.js +1486 -0
- package/src/agent/acp/README.md +347 -0
- package/src/agent/acp/connection.js +237 -0
- package/src/agent/acp/connection.test.js +311 -0
- package/src/agent/acp/examples/simple-client.js +212 -0
- package/src/agent/acp/examples/tool-lifecycle.js +230 -0
- package/src/agent/acp/final-test.js +173 -0
- package/src/agent/acp/index.js +5 -0
- package/src/agent/acp/integration.test.js +385 -0
- package/src/agent/acp/manual-test.js +410 -0
- package/src/agent/acp/protocol-test.js +190 -0
- package/src/agent/acp/server.js +448 -0
- package/src/agent/acp/server.test.js +371 -0
- package/src/agent/acp/test-runner.js +216 -0
- package/src/agent/acp/test-utils/README.md +315 -0
- package/src/agent/acp/test-utils/acp-tester.js +484 -0
- package/src/agent/acp/test-utils/mock-acp-client.js +434 -0
- package/src/agent/acp/tools.js +368 -0
- package/src/agent/acp/tools.test.js +334 -0
- package/src/agent/acp/types.js +218 -0
- package/src/agent/acp/types.test.js +327 -0
- package/src/agent/appTracer.js +360 -0
- package/src/agent/fileSpanExporter.js +169 -0
- package/src/agent/index.js +813 -0
- package/src/agent/mcp/client.js +338 -0
- package/src/agent/mcp/config.js +313 -0
- package/src/agent/mcp/index.js +64 -0
- package/src/agent/mcp/xmlBridge.js +371 -0
- package/src/agent/mockProvider.js +53 -0
- package/src/agent/probeTool.js +257 -0
- package/src/agent/schemaUtils.js +1726 -0
- package/src/agent/simpleTelemetry.js +267 -0
- package/src/agent/telemetry.js +225 -0
- package/src/agent/tokenCounter.js +395 -0
- package/src/agent/tools.js +163 -0
- package/src/cli.js +49 -0
- package/src/delegate.js +267 -0
- package/src/directory-resolver.js +237 -0
- package/src/downloader.js +750 -0
- package/src/extract.js +149 -0
- package/src/index.js +70 -0
- package/src/mcp/index.ts +608 -0
- package/src/query.js +116 -0
- package/src/search.js +247 -0
- package/src/tools/common.js +410 -0
- package/src/tools/index.js +40 -0
- package/src/tools/langchain.js +88 -0
- package/src/tools/system-message.js +121 -0
- package/src/tools/vercel.js +271 -0
- package/src/utils/file-lister.js +193 -0
- package/src/utils.js +128 -0
package/bin/probe
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from 'child_process';
|
|
4
|
+
import { join, dirname } from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { access, constants } from 'fs';
|
|
7
|
+
import { promisify } from 'util';
|
|
8
|
+
|
|
9
|
+
const accessAsync = promisify(access);
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = dirname(__filename);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Check if a file exists and is executable
|
|
15
|
+
*/
|
|
16
|
+
async function isExecutable(filePath) {
|
|
17
|
+
try {
|
|
18
|
+
await accessAsync(filePath, constants.F_OK | constants.X_OK);
|
|
19
|
+
return true;
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Attempt to download the binary if it's missing
|
|
27
|
+
*/
|
|
28
|
+
async function ensureBinary(binaryPath) {
|
|
29
|
+
try {
|
|
30
|
+
// Try to import the downloader and download the binary
|
|
31
|
+
const { downloadProbeBinary } = await import('../src/downloader.js');
|
|
32
|
+
console.log('Probe binary not found, downloading...');
|
|
33
|
+
await downloadProbeBinary();
|
|
34
|
+
|
|
35
|
+
// Check if the binary now exists and is executable
|
|
36
|
+
if (await isExecutable(binaryPath)) {
|
|
37
|
+
console.log('Binary downloaded successfully.');
|
|
38
|
+
|
|
39
|
+
// On macOS, try to remove quarantine attributes that might prevent execution
|
|
40
|
+
if (process.platform === 'darwin') {
|
|
41
|
+
try {
|
|
42
|
+
const { exec } = await import('child_process');
|
|
43
|
+
const { promisify } = await import('util');
|
|
44
|
+
const execAsync = promisify(exec);
|
|
45
|
+
await execAsync(`xattr -d com.apple.quarantine "${binaryPath}" 2>/dev/null || true`);
|
|
46
|
+
} catch {
|
|
47
|
+
// Ignore errors - this is just a precaution
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return true;
|
|
52
|
+
} else {
|
|
53
|
+
console.error('Binary downloaded but is not executable.');
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error('Failed to download binary:', error.message);
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Spawn the probe binary with proper error handling
|
|
64
|
+
*/
|
|
65
|
+
async function spawnProbeBinary(binaryPath, args) {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
const child = spawn(binaryPath, args, { stdio: 'inherit' });
|
|
68
|
+
|
|
69
|
+
child.on('error', async (error) => {
|
|
70
|
+
// Handle spawn errors, particularly the dreaded "spawn Unknown system error -8"
|
|
71
|
+
if (error.code === 'ENOENT') {
|
|
72
|
+
console.error(`Error: Binary not found at ${binaryPath}`);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
} else if (error.code === 'EACCES' || error.message.includes('spawn') || error.errno === -8) {
|
|
75
|
+
console.error(`Error: Cannot execute binary at ${binaryPath}`);
|
|
76
|
+
console.error('This might be due to:');
|
|
77
|
+
console.error('1. Missing execute permissions');
|
|
78
|
+
console.error('2. Architecture mismatch');
|
|
79
|
+
console.error('3. Corrupted binary file');
|
|
80
|
+
console.error('');
|
|
81
|
+
console.error('Attempting to re-download the binary...');
|
|
82
|
+
|
|
83
|
+
const downloadSuccess = await ensureBinary(binaryPath);
|
|
84
|
+
if (downloadSuccess) {
|
|
85
|
+
// Retry execution after download
|
|
86
|
+
try {
|
|
87
|
+
const retryChild = spawn(binaryPath, args, { stdio: 'inherit' });
|
|
88
|
+
retryChild.on('exit', (code) => resolve(code || 0));
|
|
89
|
+
retryChild.on('error', (retryError) => {
|
|
90
|
+
console.error('Failed to execute binary even after re-download:', retryError.message);
|
|
91
|
+
reject(retryError);
|
|
92
|
+
});
|
|
93
|
+
} catch (retryError) {
|
|
94
|
+
console.error('Failed to retry execution:', retryError.message);
|
|
95
|
+
reject(retryError);
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
reject(error);
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
console.error('Unexpected error:', error.message);
|
|
102
|
+
reject(error);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
child.on('exit', (code) => resolve(code || 0));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Main execution logic
|
|
111
|
+
async function main() {
|
|
112
|
+
try {
|
|
113
|
+
// Check if first argument is 'mcp'
|
|
114
|
+
if (process.argv[2] === 'mcp') {
|
|
115
|
+
// Launch MCP server instead of binary
|
|
116
|
+
const mcpPath = join(__dirname, '..', 'build', 'mcp', 'index.js');
|
|
117
|
+
const mcpArgs = process.argv.slice(3); // Remove 'node', 'probe', and 'mcp'
|
|
118
|
+
|
|
119
|
+
const child = spawn('node', [mcpPath, ...mcpArgs], { stdio: 'inherit' });
|
|
120
|
+
child.on('exit', (code) => process.exit(code || 0));
|
|
121
|
+
} else if (process.argv[2] === 'agent') {
|
|
122
|
+
// Launch Agent server instead of binary
|
|
123
|
+
const agentPath = join(__dirname, '..', 'src', 'agent', 'index.js');
|
|
124
|
+
const agentArgs = process.argv.slice(3); // Remove 'node', 'probe', and 'agent'
|
|
125
|
+
|
|
126
|
+
const child = spawn('node', [agentPath, ...agentArgs], { stdio: 'inherit' });
|
|
127
|
+
child.on('exit', (code) => process.exit(code || 0));
|
|
128
|
+
} else {
|
|
129
|
+
// Normal probe binary execution
|
|
130
|
+
const isWindows = process.platform === 'win32';
|
|
131
|
+
const binaryName = isWindows ? 'probe.exe' : 'probe-binary';
|
|
132
|
+
const binaryPath = join(__dirname, binaryName);
|
|
133
|
+
|
|
134
|
+
// Check if binary exists and is executable
|
|
135
|
+
if (!(await isExecutable(binaryPath))) {
|
|
136
|
+
console.log('Probe binary not found or not executable, attempting to download...');
|
|
137
|
+
const downloadSuccess = await ensureBinary(binaryPath);
|
|
138
|
+
if (!downloadSuccess) {
|
|
139
|
+
console.error('Failed to download probe binary. Please try installing again or check your internet connection.');
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Execute the binary
|
|
145
|
+
const exitCode = await spawnProbeBinary(binaryPath, process.argv.slice(2));
|
|
146
|
+
process.exit(exitCode);
|
|
147
|
+
}
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.error('Unexpected error in probe wrapper:', error.message);
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Run the main function
|
|
155
|
+
main().catch(error => {
|
|
156
|
+
console.error('Fatal error:', error.message);
|
|
157
|
+
process.exit(1);
|
|
158
|
+
});
|
package/bin/probe-binary
ADDED
|
Binary file
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// TypeScript definitions for ProbeAgent class
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration options for creating a ProbeAgent instance
|
|
6
|
+
*/
|
|
7
|
+
export interface ProbeAgentOptions {
|
|
8
|
+
/** Optional session ID for the agent */
|
|
9
|
+
sessionId?: string;
|
|
10
|
+
/** Custom system prompt to replace the default system message */
|
|
11
|
+
customPrompt?: string;
|
|
12
|
+
/** Predefined prompt type (persona) */
|
|
13
|
+
promptType?: 'code-explorer' | 'engineer' | 'code-review' | 'support' | 'architect';
|
|
14
|
+
/** Allow the use of the 'implement' tool for code editing */
|
|
15
|
+
allowEdit?: boolean;
|
|
16
|
+
/** Search directory path */
|
|
17
|
+
path?: string;
|
|
18
|
+
/** Force specific AI provider */
|
|
19
|
+
provider?: 'anthropic' | 'openai' | 'google';
|
|
20
|
+
/** Override model name */
|
|
21
|
+
model?: string;
|
|
22
|
+
/** Enable debug mode */
|
|
23
|
+
debug?: boolean;
|
|
24
|
+
/** Optional telemetry tracer instance */
|
|
25
|
+
tracer?: any;
|
|
26
|
+
/** Enable MCP (Model Context Protocol) tool integration */
|
|
27
|
+
enableMcp?: boolean;
|
|
28
|
+
/** Path to MCP configuration file */
|
|
29
|
+
mcpConfigPath?: string;
|
|
30
|
+
/** MCP configuration object (overrides mcpConfigPath) */
|
|
31
|
+
mcpConfig?: any;
|
|
32
|
+
/** @deprecated Use mcpConfig instead */
|
|
33
|
+
mcpServers?: any[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Tool execution event data
|
|
38
|
+
*/
|
|
39
|
+
export interface ToolCallEvent {
|
|
40
|
+
/** Unique tool call identifier */
|
|
41
|
+
id: string;
|
|
42
|
+
/** Name of the tool being called */
|
|
43
|
+
name: string;
|
|
44
|
+
/** Current execution status */
|
|
45
|
+
status: 'pending' | 'in_progress' | 'completed' | 'failed';
|
|
46
|
+
/** Tool parameters */
|
|
47
|
+
params?: any;
|
|
48
|
+
/** Tool execution result (when completed) */
|
|
49
|
+
result?: any;
|
|
50
|
+
/** Error information (when failed) */
|
|
51
|
+
error?: string;
|
|
52
|
+
/** Session ID */
|
|
53
|
+
sessionId?: string;
|
|
54
|
+
/** Execution start time */
|
|
55
|
+
startTime?: number;
|
|
56
|
+
/** Execution end time */
|
|
57
|
+
endTime?: number;
|
|
58
|
+
/** Execution duration in milliseconds */
|
|
59
|
+
duration?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Token usage statistics
|
|
64
|
+
*/
|
|
65
|
+
export interface TokenUsage {
|
|
66
|
+
/** Size of the context window */
|
|
67
|
+
contextWindow?: number;
|
|
68
|
+
/** Request tokens used */
|
|
69
|
+
request?: number;
|
|
70
|
+
/** Response tokens generated */
|
|
71
|
+
response?: number;
|
|
72
|
+
/** Total tokens (request + response) */
|
|
73
|
+
total?: number;
|
|
74
|
+
/** Cache read tokens */
|
|
75
|
+
cacheRead?: number;
|
|
76
|
+
/** Cache write tokens */
|
|
77
|
+
cacheWrite?: number;
|
|
78
|
+
/** Total request tokens across all calls */
|
|
79
|
+
totalRequest?: number;
|
|
80
|
+
/** Total response tokens across all calls */
|
|
81
|
+
totalResponse?: number;
|
|
82
|
+
/** Total tokens across all calls */
|
|
83
|
+
totalTokens?: number;
|
|
84
|
+
/** Total cache read tokens across all calls */
|
|
85
|
+
totalCacheRead?: number;
|
|
86
|
+
/** Total cache write tokens across all calls */
|
|
87
|
+
totalCacheWrite?: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Chat message structure
|
|
92
|
+
*/
|
|
93
|
+
export interface ChatMessage {
|
|
94
|
+
/** Message role */
|
|
95
|
+
role: 'user' | 'assistant' | 'system';
|
|
96
|
+
/** Message content */
|
|
97
|
+
content: string;
|
|
98
|
+
/** Optional message metadata */
|
|
99
|
+
metadata?: any;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Answer options
|
|
104
|
+
*/
|
|
105
|
+
export interface AnswerOptions {
|
|
106
|
+
/** Response schema for structured output */
|
|
107
|
+
schema?: string;
|
|
108
|
+
/** Additional context or constraints */
|
|
109
|
+
context?: string;
|
|
110
|
+
/** Maximum number of tool iterations */
|
|
111
|
+
maxIterations?: number;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* ProbeAgent class - AI-powered code exploration and interaction
|
|
116
|
+
*/
|
|
117
|
+
export declare class ProbeAgent {
|
|
118
|
+
/** Unique session identifier */
|
|
119
|
+
readonly sessionId: string;
|
|
120
|
+
|
|
121
|
+
/** Current chat history */
|
|
122
|
+
history: ChatMessage[];
|
|
123
|
+
|
|
124
|
+
/** Event emitter for tool execution updates */
|
|
125
|
+
readonly events: EventEmitter & ProbeAgentEvents;
|
|
126
|
+
|
|
127
|
+
/** Whether the agent allows code editing */
|
|
128
|
+
readonly allowEdit: boolean;
|
|
129
|
+
|
|
130
|
+
/** Allowed search folders */
|
|
131
|
+
readonly allowedFolders: string[];
|
|
132
|
+
|
|
133
|
+
/** Debug mode status */
|
|
134
|
+
readonly debug: boolean;
|
|
135
|
+
|
|
136
|
+
/** Whether operations have been cancelled */
|
|
137
|
+
cancelled: boolean;
|
|
138
|
+
|
|
139
|
+
/** AI provider being used */
|
|
140
|
+
readonly clientApiProvider?: string;
|
|
141
|
+
|
|
142
|
+
/** Current AI model */
|
|
143
|
+
readonly model?: string;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Create a new ProbeAgent instance
|
|
147
|
+
*/
|
|
148
|
+
constructor(options?: ProbeAgentOptions);
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Answer a question with optional image attachments
|
|
152
|
+
* @param message - The question or prompt
|
|
153
|
+
* @param images - Optional array of image data or paths
|
|
154
|
+
* @param options - Additional options for the response
|
|
155
|
+
* @returns Promise resolving to the AI response
|
|
156
|
+
*/
|
|
157
|
+
answer(message: string, images?: any[], options?: AnswerOptions): Promise<string>;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Get token usage statistics
|
|
161
|
+
* @returns Current token usage information
|
|
162
|
+
*/
|
|
163
|
+
getTokenUsage(): TokenUsage;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Cancel any ongoing operations
|
|
167
|
+
*/
|
|
168
|
+
cancel(): void;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Clear the conversation history
|
|
172
|
+
*/
|
|
173
|
+
clearHistory(): void;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Add a message to the conversation history
|
|
177
|
+
* @param message - Message to add
|
|
178
|
+
*/
|
|
179
|
+
addMessage(message: ChatMessage): void;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Set the conversation history
|
|
183
|
+
* @param messages - Array of chat messages
|
|
184
|
+
*/
|
|
185
|
+
setHistory(messages: ChatMessage[]): void;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* ProbeAgent Events interface
|
|
190
|
+
*/
|
|
191
|
+
export interface ProbeAgentEvents {
|
|
192
|
+
on(event: 'toolCall', listener: (event: ToolCallEvent) => void): this;
|
|
193
|
+
emit(event: 'toolCall', event: ToolCallEvent): boolean;
|
|
194
|
+
removeListener(event: 'toolCall', listener: (event: ToolCallEvent) => void): this;
|
|
195
|
+
removeAllListeners(event?: 'toolCall'): this;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Default export
|
|
199
|
+
export { ProbeAgent as default };
|