@probelabs/probe 0.6.0-rc159 → 0.6.0-rc162
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 +169 -1
- package/build/agent/FallbackManager.d.ts +176 -0
- package/build/agent/FallbackManager.js +545 -0
- package/build/agent/ProbeAgent.d.ts +7 -1
- package/build/agent/ProbeAgent.js +545 -89
- package/build/agent/RetryManager.d.ts +157 -0
- package/build/agent/RetryManager.js +334 -0
- package/build/agent/acp/tools.js +6 -2
- package/build/agent/contextCompactor.js +271 -0
- package/build/agent/index.js +2165 -250
- package/build/agent/probeTool.js +20 -2
- package/build/agent/schemaUtils.js +7 -0
- package/build/agent/tools.js +16 -0
- package/build/agent/xmlParsingUtils.js +24 -4
- package/build/index.js +13 -0
- package/build/tools/common.js +21 -4
- package/build/tools/edit.js +409 -0
- package/build/tools/index.js +11 -0
- package/cjs/agent/ProbeAgent.cjs +2620 -606
- package/cjs/index.cjs +2582 -563
- package/package.json +2 -2
- package/src/agent/FallbackManager.d.ts +176 -0
- package/src/agent/FallbackManager.js +545 -0
- package/src/agent/ProbeAgent.d.ts +7 -1
- package/src/agent/ProbeAgent.js +545 -89
- package/src/agent/RetryManager.d.ts +157 -0
- package/src/agent/RetryManager.js +334 -0
- package/src/agent/acp/tools.js +6 -2
- package/src/agent/contextCompactor.js +271 -0
- package/src/agent/index.js +30 -1
- package/src/agent/probeTool.js +20 -2
- package/src/agent/schemaUtils.js +7 -0
- package/src/agent/tools.js +16 -0
- package/src/agent/xmlParsingUtils.js +24 -4
- package/src/index.js +13 -0
- package/src/tools/common.js +21 -4
- package/src/tools/edit.js +409 -0
- package/src/tools/index.js +11 -0
- package/bin/binaries/probe-v0.6.0-rc159-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc159-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc159-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc159-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc159-x86_64-unknown-linux-musl.tar.gz +0 -0
package/README.md
CHANGED
|
@@ -29,6 +29,7 @@ During installation, the package will automatically download the appropriate pro
|
|
|
29
29
|
- **Automatic Binary Management**: Automatically downloads and manages the probe binary
|
|
30
30
|
- **Direct CLI Access**: Use the probe binary directly from the command line when installed globally
|
|
31
31
|
- **MCP Server**: Built-in Model Context Protocol server for AI assistant integration
|
|
32
|
+
- **Context Window Compaction**: Automatic conversation history compression when approaching token limits
|
|
32
33
|
|
|
33
34
|
## Usage
|
|
34
35
|
|
|
@@ -92,6 +93,7 @@ const agent = new ProbeAgent({
|
|
|
92
93
|
model: 'claude-3-5-sonnet-20241022', // Optional: override model
|
|
93
94
|
allowEdit: false, // Optional: enable code modification
|
|
94
95
|
debug: true, // Optional: enable debug logging
|
|
96
|
+
allowedTools: ['*'], // Optional: filter available tools (see Tool Filtering below)
|
|
95
97
|
enableMcp: true, // Optional: enable MCP tool integration
|
|
96
98
|
mcpConfig: { // Optional: MCP configuration (see MCP section below)
|
|
97
99
|
mcpServers: {...}
|
|
@@ -131,11 +133,170 @@ export MODEL_NAME=claude-3-5-sonnet-20241022
|
|
|
131
133
|
**ProbeAgent Features:**
|
|
132
134
|
- **Multi-turn conversations** with automatic history management
|
|
133
135
|
- **Code search integration** - Uses probe's search capabilities transparently
|
|
134
|
-
- **Multiple AI providers** - Supports Anthropic Claude, OpenAI GPT, Google Gemini
|
|
136
|
+
- **Multiple AI providers** - Supports Anthropic Claude, OpenAI GPT, Google Gemini, AWS Bedrock
|
|
137
|
+
- **Automatic retry with exponential backoff** - Handles transient API failures gracefully
|
|
138
|
+
- **Provider fallback** - Seamlessly switch between providers if one fails (e.g., Azure Claude → Bedrock Claude → OpenAI)
|
|
135
139
|
- **Session management** - Maintain conversation context across calls
|
|
136
140
|
- **Token tracking** - Monitor usage and costs
|
|
137
141
|
- **Configurable personas** - Engineer, architect, code-review, and more
|
|
138
142
|
|
|
143
|
+
### Retry and Fallback Support
|
|
144
|
+
|
|
145
|
+
ProbeAgent includes comprehensive retry and fallback capabilities for maximum reliability:
|
|
146
|
+
|
|
147
|
+
```javascript
|
|
148
|
+
import { ProbeAgent } from '@probelabs/probe';
|
|
149
|
+
|
|
150
|
+
const agent = new ProbeAgent({
|
|
151
|
+
path: '/path/to/your/project',
|
|
152
|
+
|
|
153
|
+
// Configure retry behavior
|
|
154
|
+
retry: {
|
|
155
|
+
maxRetries: 5, // Retry up to 5 times per provider
|
|
156
|
+
initialDelay: 1000, // Start with 1 second delay
|
|
157
|
+
maxDelay: 30000, // Cap delays at 30 seconds
|
|
158
|
+
backoffFactor: 2 // Double the delay each time
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
// Configure provider fallback
|
|
162
|
+
fallback: {
|
|
163
|
+
strategy: 'custom',
|
|
164
|
+
providers: [
|
|
165
|
+
{
|
|
166
|
+
provider: 'anthropic',
|
|
167
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
168
|
+
model: 'claude-3-7-sonnet-20250219',
|
|
169
|
+
maxRetries: 5 // Can override retry config per provider
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
provider: 'bedrock',
|
|
173
|
+
region: 'us-west-2',
|
|
174
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
175
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
176
|
+
model: 'anthropic.claude-sonnet-4-20250514-v1:0'
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
provider: 'openai',
|
|
180
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
181
|
+
model: 'gpt-4o'
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
maxTotalAttempts: 15 // Maximum attempts across all providers
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// API calls automatically retry on failures and fallback to other providers
|
|
189
|
+
const answer = await agent.answer("Explain this codebase");
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Retry & Fallback Features:**
|
|
193
|
+
- **Exponential backoff** - Intelligently delays retries to avoid overwhelming APIs
|
|
194
|
+
- **Automatic error detection** - Retries on transient errors (Overloaded, 429, 503, timeouts, network errors)
|
|
195
|
+
- **Multi-provider support** - Fallback across Anthropic, OpenAI, Google, and AWS Bedrock
|
|
196
|
+
- **Cross-cloud failover** - Use Azure Claude → Bedrock Claude → OpenAI as fallback chain
|
|
197
|
+
- **Statistics tracking** - Monitor retry attempts and provider usage
|
|
198
|
+
- **Environment variable support** - Configure via env vars for easy deployment
|
|
199
|
+
|
|
200
|
+
**Quick Setup with Auto-Fallback:**
|
|
201
|
+
```bash
|
|
202
|
+
# Set all your API keys
|
|
203
|
+
export ANTHROPIC_API_KEY=sk-ant-xxx
|
|
204
|
+
export OPENAI_API_KEY=sk-xxx
|
|
205
|
+
export GOOGLE_API_KEY=xxx
|
|
206
|
+
export AUTO_FALLBACK=1 # Enable automatic fallback
|
|
207
|
+
export MAX_RETRIES=5 # Configure retry limit
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
// No configuration needed - uses all available providers automatically!
|
|
212
|
+
const agent = new ProbeAgent({
|
|
213
|
+
path: '/path/to/your/project',
|
|
214
|
+
fallback: { auto: true }
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
See [docs/RETRY_AND_FALLBACK.md](./docs/RETRY_AND_FALLBACK.md) for complete documentation and examples.
|
|
219
|
+
|
|
220
|
+
### Tool Filtering
|
|
221
|
+
|
|
222
|
+
ProbeAgent supports filtering available tools to control what operations the AI can perform. This is useful for security, cost control, or limiting functionality to specific use cases.
|
|
223
|
+
|
|
224
|
+
```javascript
|
|
225
|
+
import { ProbeAgent } from '@probelabs/probe';
|
|
226
|
+
|
|
227
|
+
// Allow all tools (default behavior)
|
|
228
|
+
const agent1 = new ProbeAgent({
|
|
229
|
+
path: '/path/to/project',
|
|
230
|
+
allowedTools: ['*'] // or undefined
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// Allow only specific tools (whitelist mode)
|
|
234
|
+
const agent2 = new ProbeAgent({
|
|
235
|
+
path: '/path/to/project',
|
|
236
|
+
allowedTools: ['search', 'query', 'extract']
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// Allow all except specific tools (exclusion mode)
|
|
240
|
+
const agent3 = new ProbeAgent({
|
|
241
|
+
path: '/path/to/project',
|
|
242
|
+
allowedTools: ['*', '!bash', '!implement']
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// Raw AI mode - no tools at all
|
|
246
|
+
const agent4 = new ProbeAgent({
|
|
247
|
+
path: '/path/to/project',
|
|
248
|
+
allowedTools: [] // or use disableTools: true
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// Convenience flag for raw AI mode (better DX)
|
|
252
|
+
const agent5 = new ProbeAgent({
|
|
253
|
+
path: '/path/to/project',
|
|
254
|
+
disableTools: true // Clearer than allowedTools: []
|
|
255
|
+
});
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Available Tools:**
|
|
259
|
+
- `search` - Semantic code search
|
|
260
|
+
- `query` - Tree-sitter pattern matching
|
|
261
|
+
- `extract` - Extract code blocks
|
|
262
|
+
- `listFiles` - List files and directories
|
|
263
|
+
- `searchFiles` - Find files by glob pattern
|
|
264
|
+
- `bash` - Execute bash commands (requires `enableBash: true`)
|
|
265
|
+
- `implement` - Implement features with aider (requires `allowEdit: true`)
|
|
266
|
+
- `edit` - Edit files with exact string replacement (requires `allowEdit: true`)
|
|
267
|
+
- `create` - Create new files (requires `allowEdit: true`)
|
|
268
|
+
- `delegate` - Delegate tasks to subagents (requires `enableDelegate: true`)
|
|
269
|
+
- `attempt_completion` - Signal task completion
|
|
270
|
+
- `mcp__*` - MCP tools use the `mcp__` prefix (e.g., `mcp__filesystem__read_file`)
|
|
271
|
+
|
|
272
|
+
**MCP Tool Filtering:**
|
|
273
|
+
MCP tools follow the `mcp__toolname` naming convention. You can:
|
|
274
|
+
- Allow all MCP tools: `allowedTools: ['*']`
|
|
275
|
+
- Allow specific MCP tool: `allowedTools: ['mcp__filesystem__read_file']`
|
|
276
|
+
- Allow all from a server: `allowedTools: ['mcp__filesystem__*']` (using pattern matching)
|
|
277
|
+
- Block MCP tools: `allowedTools: ['*', '!mcp__*']`
|
|
278
|
+
|
|
279
|
+
**CLI Usage:**
|
|
280
|
+
```bash
|
|
281
|
+
# Allow only search and extract tools
|
|
282
|
+
probe agent "Explain this code" --allowed-tools search,extract
|
|
283
|
+
|
|
284
|
+
# Raw AI mode (no tools) - option 1
|
|
285
|
+
probe agent "What is this project about?" --allowed-tools none
|
|
286
|
+
|
|
287
|
+
# Raw AI mode (no tools) - option 2 (better DX)
|
|
288
|
+
probe agent "Tell me about this project" --disable-tools
|
|
289
|
+
|
|
290
|
+
# All tools (default)
|
|
291
|
+
probe agent "Analyze the architecture" --allowed-tools all
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Notes:**
|
|
295
|
+
- Tool filtering works in conjunction with feature flags (`allowEdit`, `enableBash`, `enableDelegate`)
|
|
296
|
+
- Both the feature flag AND `allowedTools` must permit a tool for it to be available
|
|
297
|
+
- Blocked tools will not appear in the system message and cannot be executed
|
|
298
|
+
- Use `allowedTools: []` for pure conversational AI without code analysis tools
|
|
299
|
+
|
|
139
300
|
### Using as an MCP Server
|
|
140
301
|
|
|
141
302
|
Probe includes a built-in MCP (Model Context Protocol) server for integration with AI assistants:
|
|
@@ -612,6 +773,13 @@ probe mcp --timeout 60
|
|
|
612
773
|
}
|
|
613
774
|
```
|
|
614
775
|
|
|
776
|
+
## Additional Documentation
|
|
777
|
+
|
|
778
|
+
- [Context Window Compaction](./CONTEXT_COMPACTION.md) - Automatic conversation history compression
|
|
779
|
+
- [MCP Integration](./MCP_INTEGRATION_SUMMARY.md) - Model Context Protocol support details
|
|
780
|
+
- [Delegate Tool](./DELEGATE_TOOL_README.md) - Task distribution to subagents
|
|
781
|
+
- [Maid Integration](./MAID_INTEGRATION.md) - Integration with Maid LLM framework
|
|
782
|
+
|
|
615
783
|
## Related Projects
|
|
616
784
|
|
|
617
785
|
- [probe](https://github.com/probelabs/probe) - The core probe code search tool
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript type definitions for FallbackManager
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Fallback strategies
|
|
7
|
+
*/
|
|
8
|
+
export const FALLBACK_STRATEGIES: {
|
|
9
|
+
/** Try same model on different providers */
|
|
10
|
+
SAME_MODEL: 'same-model';
|
|
11
|
+
/** Try different models on same provider */
|
|
12
|
+
SAME_PROVIDER: 'same-provider';
|
|
13
|
+
/** Try any available provider/model */
|
|
14
|
+
ANY: 'any';
|
|
15
|
+
/** Use custom provider list */
|
|
16
|
+
CUSTOM: 'custom';
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type FallbackStrategy =
|
|
20
|
+
| 'same-model'
|
|
21
|
+
| 'same-provider'
|
|
22
|
+
| 'any'
|
|
23
|
+
| 'custom';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Provider configuration
|
|
27
|
+
*/
|
|
28
|
+
export interface ProviderConfig {
|
|
29
|
+
/** Provider name */
|
|
30
|
+
provider: 'anthropic' | 'openai' | 'google' | 'bedrock';
|
|
31
|
+
/** Model name (uses provider default if omitted) */
|
|
32
|
+
model?: string;
|
|
33
|
+
/** API key for the provider */
|
|
34
|
+
apiKey?: string;
|
|
35
|
+
/** Custom API endpoint */
|
|
36
|
+
baseURL?: string;
|
|
37
|
+
/** Max retries for this provider (overrides global) */
|
|
38
|
+
maxRetries?: number;
|
|
39
|
+
|
|
40
|
+
// AWS Bedrock specific
|
|
41
|
+
/** AWS region (for Bedrock) */
|
|
42
|
+
region?: string;
|
|
43
|
+
/** AWS access key ID (for Bedrock) */
|
|
44
|
+
accessKeyId?: string;
|
|
45
|
+
/** AWS secret access key (for Bedrock) */
|
|
46
|
+
secretAccessKey?: string;
|
|
47
|
+
/** AWS session token (for Bedrock) */
|
|
48
|
+
sessionToken?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Fallback configuration options
|
|
53
|
+
*/
|
|
54
|
+
export interface FallbackOptions {
|
|
55
|
+
/** Fallback strategy */
|
|
56
|
+
strategy?: FallbackStrategy;
|
|
57
|
+
/** List of models for same-provider fallback */
|
|
58
|
+
models?: string[];
|
|
59
|
+
/** List of provider configurations for custom fallback */
|
|
60
|
+
providers?: ProviderConfig[];
|
|
61
|
+
/** Stop on first successful response */
|
|
62
|
+
stopOnSuccess?: boolean;
|
|
63
|
+
/** Continue to fallback on non-retryable errors */
|
|
64
|
+
continueOnNonRetryableError?: boolean;
|
|
65
|
+
/** Maximum total attempts across all providers (1-100) */
|
|
66
|
+
maxTotalAttempts?: number;
|
|
67
|
+
/** Enable debug logging */
|
|
68
|
+
debug?: boolean;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Fallback statistics
|
|
73
|
+
*/
|
|
74
|
+
export interface FallbackStats {
|
|
75
|
+
/** Total number of provider attempts */
|
|
76
|
+
totalAttempts: number;
|
|
77
|
+
/** Number of attempts per provider */
|
|
78
|
+
providerAttempts: Record<string, number>;
|
|
79
|
+
/** Name of the successful provider */
|
|
80
|
+
successfulProvider: string | null;
|
|
81
|
+
/** List of failed providers with error details */
|
|
82
|
+
failedProviders: Array<{
|
|
83
|
+
provider: string;
|
|
84
|
+
error: {
|
|
85
|
+
message: string;
|
|
86
|
+
type: string;
|
|
87
|
+
statusCode?: number;
|
|
88
|
+
};
|
|
89
|
+
}>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Auto-fallback provider build options
|
|
94
|
+
*/
|
|
95
|
+
export interface BuildFallbackOptions {
|
|
96
|
+
/** Primary provider to try first */
|
|
97
|
+
primaryProvider?: string;
|
|
98
|
+
/** Primary model to use */
|
|
99
|
+
primaryModel?: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* FallbackManager class for handling provider and model fallback
|
|
104
|
+
*/
|
|
105
|
+
export class FallbackManager {
|
|
106
|
+
/** Fallback strategy */
|
|
107
|
+
strategy: FallbackStrategy;
|
|
108
|
+
/** List of models for same-provider fallback */
|
|
109
|
+
models: string[];
|
|
110
|
+
/** List of provider configurations */
|
|
111
|
+
providers: ProviderConfig[];
|
|
112
|
+
/** Stop on first success */
|
|
113
|
+
stopOnSuccess: boolean;
|
|
114
|
+
/** Continue on non-retryable errors */
|
|
115
|
+
continueOnNonRetryableError: boolean;
|
|
116
|
+
/** Maximum total attempts */
|
|
117
|
+
maxTotalAttempts: number;
|
|
118
|
+
/** Debug logging enabled */
|
|
119
|
+
debug: boolean;
|
|
120
|
+
/** Fallback statistics */
|
|
121
|
+
stats: FallbackStats;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Create a new FallbackManager
|
|
125
|
+
* @param options - Fallback configuration options
|
|
126
|
+
*/
|
|
127
|
+
constructor(options?: FallbackOptions);
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Execute a function with fallback support
|
|
131
|
+
* @param fn - Function that takes (provider, model, config) and returns a Promise
|
|
132
|
+
* @returns Result from the function
|
|
133
|
+
* @throws Error if all fallbacks are exhausted
|
|
134
|
+
*/
|
|
135
|
+
executeWithFallback<T>(
|
|
136
|
+
fn: (
|
|
137
|
+
provider: any,
|
|
138
|
+
model: string,
|
|
139
|
+
config: ProviderConfig
|
|
140
|
+
) => Promise<T>
|
|
141
|
+
): Promise<T>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Get fallback statistics
|
|
145
|
+
* @returns Statistics object (copy)
|
|
146
|
+
*/
|
|
147
|
+
getStats(): FallbackStats;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Reset statistics
|
|
151
|
+
*/
|
|
152
|
+
resetStats(): void;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Create a FallbackManager from environment variables
|
|
157
|
+
* @param debug - Enable debug logging
|
|
158
|
+
* @returns Configured FallbackManager instance or null if no config found
|
|
159
|
+
*/
|
|
160
|
+
export function createFallbackManagerFromEnv(
|
|
161
|
+
debug?: boolean
|
|
162
|
+
): FallbackManager | null;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Build a fallback provider list from current environment
|
|
166
|
+
* @param options - Options for building the list
|
|
167
|
+
* @returns List of provider configurations
|
|
168
|
+
*/
|
|
169
|
+
export function buildFallbackProvidersFromEnv(
|
|
170
|
+
options?: BuildFallbackOptions
|
|
171
|
+
): ProviderConfig[];
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Default model mappings for each provider
|
|
175
|
+
*/
|
|
176
|
+
export const DEFAULT_MODELS: Record<string, string>;
|