@probelabs/probe 0.6.0-rc302 → 0.6.0-rc304
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/bin/binaries/{probe-v0.6.0-rc302-aarch64-apple-darwin.tar.gz → probe-v0.6.0-rc304-aarch64-apple-darwin.tar.gz} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc302-aarch64-unknown-linux-musl.tar.gz → probe-v0.6.0-rc304-aarch64-unknown-linux-musl.tar.gz} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc302-x86_64-apple-darwin.tar.gz → probe-v0.6.0-rc304-x86_64-apple-darwin.tar.gz} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc302-x86_64-pc-windows-msvc.zip → probe-v0.6.0-rc304-x86_64-pc-windows-msvc.zip} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc302-x86_64-unknown-linux-musl.tar.gz → probe-v0.6.0-rc304-x86_64-unknown-linux-musl.tar.gz} +0 -0
- package/build/agent/FallbackManager.js +3 -57
- package/build/agent/ProbeAgent.js +48 -62
- package/build/delegate.js +15 -4
- package/build/tools/common.js +16 -1
- package/build/tools/vercel.js +448 -209
- package/build/utils/provider.js +106 -0
- package/cjs/agent/ProbeAgent.cjs +1078 -305
- package/cjs/index.cjs +529 -303
- package/package.json +1 -1
- package/src/agent/FallbackManager.js +3 -57
- package/src/agent/ProbeAgent.js +48 -62
- package/src/delegate.js +15 -4
- package/src/tools/common.js +16 -1
- package/src/tools/vercel.js +448 -209
- package/src/utils/provider.js +106 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared provider/model creation utilities.
|
|
3
|
+
* Single source of truth for AI SDK provider instantiation.
|
|
4
|
+
* Used by FallbackManager, ProbeAgent, and lightweight LLM calls (e.g., dedup checker).
|
|
5
|
+
* @module utils/provider
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
9
|
+
import { createOpenAI } from '@ai-sdk/openai';
|
|
10
|
+
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|
11
|
+
import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';
|
|
12
|
+
|
|
13
|
+
export const DEFAULT_MODELS = {
|
|
14
|
+
anthropic: 'claude-sonnet-4-6',
|
|
15
|
+
openai: 'gpt-5.2',
|
|
16
|
+
google: 'gemini-2.5-flash',
|
|
17
|
+
bedrock: 'anthropic.claude-sonnet-4-6'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Create a provider instance from a config object.
|
|
22
|
+
* @param {{ provider: string, apiKey?: string, baseURL?: string, region?: string, accessKeyId?: string, secretAccessKey?: string, sessionToken?: string }} config
|
|
23
|
+
* @returns {object} AI SDK provider instance
|
|
24
|
+
*/
|
|
25
|
+
export function createProviderInstance(config) {
|
|
26
|
+
switch (config.provider) {
|
|
27
|
+
case 'anthropic':
|
|
28
|
+
return createAnthropic({
|
|
29
|
+
apiKey: config.apiKey,
|
|
30
|
+
...(config.baseURL && { baseURL: config.baseURL })
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
case 'openai':
|
|
34
|
+
return createOpenAI({
|
|
35
|
+
compatibility: 'strict',
|
|
36
|
+
apiKey: config.apiKey,
|
|
37
|
+
...(config.baseURL && { baseURL: config.baseURL })
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
case 'google':
|
|
41
|
+
return createGoogleGenerativeAI({
|
|
42
|
+
apiKey: config.apiKey,
|
|
43
|
+
...(config.baseURL && { baseURL: config.baseURL })
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
case 'bedrock': {
|
|
47
|
+
const bedrockConfig = {};
|
|
48
|
+
if (config.apiKey) {
|
|
49
|
+
bedrockConfig.apiKey = config.apiKey;
|
|
50
|
+
} else if (config.accessKeyId && config.secretAccessKey) {
|
|
51
|
+
bedrockConfig.accessKeyId = config.accessKeyId;
|
|
52
|
+
bedrockConfig.secretAccessKey = config.secretAccessKey;
|
|
53
|
+
if (config.sessionToken) {
|
|
54
|
+
bedrockConfig.sessionToken = config.sessionToken;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (config.region) bedrockConfig.region = config.region;
|
|
58
|
+
if (config.baseURL) bedrockConfig.baseURL = config.baseURL;
|
|
59
|
+
return createAmazonBedrock(bedrockConfig);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
default:
|
|
63
|
+
throw new Error(`Unknown provider "${config.provider}"`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Resolve API key for a provider from environment variables.
|
|
69
|
+
* @param {string} providerName - 'anthropic' | 'openai' | 'google' | 'bedrock'
|
|
70
|
+
* @returns {string|undefined}
|
|
71
|
+
*/
|
|
72
|
+
export function resolveApiKey(providerName) {
|
|
73
|
+
switch (providerName) {
|
|
74
|
+
case 'anthropic':
|
|
75
|
+
return process.env.ANTHROPIC_API_KEY || process.env.ANTHROPIC_AUTH_TOKEN;
|
|
76
|
+
case 'openai':
|
|
77
|
+
return process.env.OPENAI_API_KEY;
|
|
78
|
+
case 'google':
|
|
79
|
+
return process.env.GOOGLE_GENERATIVE_AI_API_KEY || process.env.GOOGLE_API_KEY || process.env.GEMINI_API_KEY;
|
|
80
|
+
case 'bedrock':
|
|
81
|
+
return process.env.AWS_BEDROCK_API_KEY;
|
|
82
|
+
default:
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Create a language model instance from provider name + model name.
|
|
89
|
+
* Resolves API keys from environment automatically.
|
|
90
|
+
* Returns null on failure (graceful degradation for optional features).
|
|
91
|
+
* @param {string} providerName - 'anthropic' | 'openai' | 'google' | 'bedrock'
|
|
92
|
+
* @param {string} modelName - Model identifier (e.g., 'gemini-2.0-flash')
|
|
93
|
+
* @returns {Promise<object|null>} AI SDK model instance, or null
|
|
94
|
+
*/
|
|
95
|
+
export async function createLanguageModel(providerName, modelName) {
|
|
96
|
+
if (!providerName) return null;
|
|
97
|
+
const resolvedModel = modelName || DEFAULT_MODELS[providerName];
|
|
98
|
+
if (!resolvedModel) return null;
|
|
99
|
+
try {
|
|
100
|
+
const apiKey = resolveApiKey(providerName);
|
|
101
|
+
const provider = createProviderInstance({ provider: providerName, ...(apiKey ? { apiKey } : {}) });
|
|
102
|
+
return provider(resolvedModel);
|
|
103
|
+
} catch {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|