@agi-cli/sdk 0.1.135 → 0.1.136
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/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agi-cli/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.136",
|
|
4
4
|
"description": "AI agent SDK for building intelligent assistants - tree-shakable and comprehensive",
|
|
5
|
-
"author": "
|
|
5
|
+
"author": "nitishxyz",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://github.com/
|
|
7
|
+
"homepage": "https://github.com/nitishxyz/agi#readme",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/
|
|
10
|
+
"url": "git+https://github.com/nitishxyz/agi.git",
|
|
11
11
|
"directory": "packages/sdk"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/
|
|
14
|
+
"url": "https://github.com/nitishxyz/agi/issues"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"main": "./src/index.ts",
|
|
@@ -16,6 +16,8 @@ const isAllowedOpenAIModel = (id: string): boolean => {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const isAllowedAnthropicModel = (id: string): boolean => {
|
|
19
|
+
if (id.includes('-3-5-') || id.includes('-3.5-')) return true;
|
|
20
|
+
if (id.match(/claude-(haiku|sonnet|opus)-3/)) return true;
|
|
19
21
|
if (id.includes('-4-') || id.includes('-4.')) return true;
|
|
20
22
|
if (id.match(/claude-(haiku|sonnet|opus)-4/)) return true;
|
|
21
23
|
return false;
|
|
@@ -9,6 +9,34 @@ import { createOpenAI } from '@ai-sdk/openai';
|
|
|
9
9
|
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
10
10
|
import { addAnthropicCacheControl } from './anthropic-caching.ts';
|
|
11
11
|
|
|
12
|
+
function simplifyPaymentError(errMsg: string): string {
|
|
13
|
+
const lower = errMsg.toLowerCase();
|
|
14
|
+
if (
|
|
15
|
+
lower.includes('insufficient') ||
|
|
16
|
+
lower.includes('not enough') ||
|
|
17
|
+
lower.includes('balance')
|
|
18
|
+
) {
|
|
19
|
+
return 'Insufficient USDC balance';
|
|
20
|
+
}
|
|
21
|
+
if (lower.includes('simulation') || lower.includes('compute unit')) {
|
|
22
|
+
return 'Transaction simulation failed';
|
|
23
|
+
}
|
|
24
|
+
if (lower.includes('blockhash') || lower.includes('expired')) {
|
|
25
|
+
return 'Transaction expired, please retry';
|
|
26
|
+
}
|
|
27
|
+
if (lower.includes('timeout') || lower.includes('timed out')) {
|
|
28
|
+
return 'Transaction timed out';
|
|
29
|
+
}
|
|
30
|
+
if (lower.includes('rejected') || lower.includes('cancelled')) {
|
|
31
|
+
return 'Transaction rejected';
|
|
32
|
+
}
|
|
33
|
+
if (lower.includes('network') || lower.includes('connection')) {
|
|
34
|
+
return 'Network error';
|
|
35
|
+
}
|
|
36
|
+
const short = errMsg.split('.')[0].slice(0, 80);
|
|
37
|
+
return short.length < errMsg.length ? `${short}...` : errMsg;
|
|
38
|
+
}
|
|
39
|
+
|
|
12
40
|
const DEFAULT_BASE_URL = 'https://router.solforge.sh';
|
|
13
41
|
const DEFAULT_RPC_URL = 'https://api.mainnet-beta.solana.com';
|
|
14
42
|
const DEFAULT_MAX_ATTEMPTS = 3;
|
|
@@ -330,13 +358,7 @@ async function processSinglePayment(args: {
|
|
|
330
358
|
paymentPayload = await createPaymentPayload(args);
|
|
331
359
|
} catch (err) {
|
|
332
360
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
333
|
-
const
|
|
334
|
-
errMsg.toLowerCase().includes('insufficient') ||
|
|
335
|
-
errMsg.toLowerCase().includes('not enough') ||
|
|
336
|
-
errMsg.toLowerCase().includes('balance');
|
|
337
|
-
const userMsg = isInsufficientFunds
|
|
338
|
-
? 'Insufficient USDC balance in wallet for payment'
|
|
339
|
-
: `Payment failed: ${errMsg}`;
|
|
361
|
+
const userMsg = `Payment failed: ${simplifyPaymentError(errMsg)}`;
|
|
340
362
|
args.callbacks.onPaymentError?.(userMsg);
|
|
341
363
|
throw new Error(`Solforge: ${userMsg}`);
|
|
342
364
|
}
|
|
@@ -37,11 +37,16 @@ const PREFERRED_FAST_MODELS: Partial<Record<ProviderId, string[]>> = {
|
|
|
37
37
|
'gemini-2.5-flash-lite',
|
|
38
38
|
],
|
|
39
39
|
openrouter: [
|
|
40
|
+
'anthropic/claude-3.5-haiku',
|
|
40
41
|
'openai/gpt-4o-mini',
|
|
41
42
|
'google/gemini-2.0-flash-001',
|
|
42
|
-
'anthropic/claude-3.5-haiku',
|
|
43
43
|
],
|
|
44
|
-
opencode: ['
|
|
44
|
+
opencode: ['claude-3-5-haiku', 'gpt-5-nano', 'gemini-3-flash'],
|
|
45
|
+
solforge: [
|
|
46
|
+
'claude-3-5-haiku-latest',
|
|
47
|
+
'claude-3-5-haiku-20241022',
|
|
48
|
+
'codex-mini-latest',
|
|
49
|
+
],
|
|
45
50
|
zai: ['glm-4.5-flash', 'glm-4.5-air'],
|
|
46
51
|
};
|
|
47
52
|
|