@agi-cli/sdk 0.1.141 → 0.1.143

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 CHANGED
@@ -72,7 +72,7 @@ import {
72
72
  } from '@agi-cli/sdk';
73
73
 
74
74
  // Check available providers
75
- console.log(providerIds); // ['openai', 'anthropic', 'google', 'openrouter', 'opencode', 'solforge']
75
+ console.log(providerIds); // ['openai', 'anthropic', 'google', 'openrouter', 'opencode', 'setu']
76
76
 
77
77
  // Get model information
78
78
  const models = catalog.anthropic.models;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agi-cli/sdk",
3
- "version": "0.1.141",
3
+ "version": "0.1.143",
4
4
  "description": "AI agent SDK for building intelligent assistants - tree-shakable and comprehensive",
5
5
  "author": "nitishxyz",
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@ const DEFAULTS: {
25
25
  google: { enabled: true },
26
26
  openrouter: { enabled: false },
27
27
  opencode: { enabled: false },
28
- solforge: { enabled: false },
28
+ setu: { enabled: false },
29
29
  zai: { enabled: false },
30
30
  'zai-coding': { enabled: false },
31
31
  moonshot: { enabled: false },
@@ -5,7 +5,7 @@ import { createOpenRouter } from '@openrouter/ai-sdk-provider';
5
5
  import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
6
6
  import {
7
7
  catalog,
8
- createSolforgeModel,
8
+ createSetuModel,
9
9
  createOpenAIOAuthModel,
10
10
  } from '../../../providers/src/index.ts';
11
11
  import type { OAuth } from '../../../types/src/index.ts';
@@ -33,7 +33,7 @@ export type ProviderName =
33
33
  | 'google'
34
34
  | 'openrouter'
35
35
  | 'opencode'
36
- | 'solforge'
36
+ | 'setu'
37
37
  | 'zai'
38
38
  | 'zai-coding'
39
39
  | 'moonshot';
@@ -152,16 +152,16 @@ export async function resolveModel(
152
152
  return ocOpenAI(resolvedModelId);
153
153
  }
154
154
 
155
- if (provider === 'solforge') {
156
- const privateKey = config.apiKey || process.env.SOLFORGE_PRIVATE_KEY || '';
155
+ if (provider === 'setu') {
156
+ const privateKey = config.apiKey || process.env.SETU_PRIVATE_KEY || '';
157
157
  if (!privateKey) {
158
158
  throw new Error(
159
- 'Solforge provider requires SOLFORGE_PRIVATE_KEY (base58 Solana secret).',
159
+ 'Setu provider requires SETU_PRIVATE_KEY (base58 Solana secret).',
160
160
  );
161
161
  }
162
- const baseURL = config.baseURL || process.env.SOLFORGE_BASE_URL;
163
- const rpcURL = process.env.SOLFORGE_SOLANA_RPC_URL;
164
- return createSolforgeModel(
162
+ const baseURL = config.baseURL || process.env.SETU_BASE_URL;
163
+ const rpcURL = process.env.SETU_SOLANA_RPC_URL;
164
+ return createSetuModel(
165
165
  model,
166
166
  { privateKey },
167
167
  {
package/src/index.ts CHANGED
@@ -61,16 +61,16 @@ export {
61
61
  setEnvKey,
62
62
  } from './providers/src/index.ts';
63
63
  export {
64
- createSolforgeFetch,
65
- createSolforgeModel,
66
- fetchSolforgeBalance,
64
+ createSetuFetch,
65
+ createSetuModel,
66
+ fetchSetuBalance,
67
67
  getPublicKeyFromPrivate,
68
68
  fetchSolanaUsdcBalance,
69
69
  } from './providers/src/index.ts';
70
70
  export type {
71
- SolforgeAuth,
72
- SolforgeProviderOptions,
73
- SolforgeBalanceResponse,
71
+ SetuAuth,
72
+ SetuProviderOptions,
73
+ SetuBalanceResponse,
74
74
  SolanaUsdcBalanceResponse,
75
75
  } from './providers/src/index.ts';
76
76
  export {
@@ -62,12 +62,12 @@ export async function providerBasePrompt(
62
62
  }
63
63
  }
64
64
 
65
- // 2) Provider-family fallback for openrouter/opencode/solforge using embedded defaults
65
+ // 2) Provider-family fallback for openrouter/opencode/setu using embedded defaults
66
66
  if (
67
67
  isProviderId(id) &&
68
68
  (id === 'openrouter' ||
69
69
  id === 'opencode' ||
70
- id === 'solforge' ||
70
+ id === 'setu' ||
71
71
  id === 'zai' ||
72
72
  id === 'zai-coding') &&
73
73
  modelId
@@ -6,7 +6,7 @@ import type {
6
6
 
7
7
  type CatalogMap = Partial<Record<ProviderId, ProviderCatalogEntry>>;
8
8
 
9
- const SOLFORGE_ID: ProviderId = 'solforge';
9
+ const SETU_ID: ProviderId = 'setu';
10
10
 
11
11
  const isAllowedOpenAIModel = (id: string): boolean => {
12
12
  if (id === 'codex-mini-latest') return true;
@@ -23,7 +23,7 @@ const isAllowedAnthropicModel = (id: string): boolean => {
23
23
  return false;
24
24
  };
25
25
 
26
- const SOLFORGE_SOURCES: Array<{ id: ProviderId; npm: string }> = [
26
+ const SETU_SOURCES: Array<{ id: ProviderId; npm: string }> = [
27
27
  {
28
28
  id: 'openai',
29
29
  npm: '@ai-sdk/openai',
@@ -32,6 +32,10 @@ const SOLFORGE_SOURCES: Array<{ id: ProviderId; npm: string }> = [
32
32
  id: 'anthropic',
33
33
  npm: '@ai-sdk/anthropic',
34
34
  },
35
+ {
36
+ id: 'moonshot',
37
+ npm: '@ai-sdk/openai-compatible',
38
+ },
35
39
  ];
36
40
 
37
41
  function cloneModel(model: ModelInfo): ModelInfo {
@@ -53,8 +57,8 @@ function cloneModel(model: ModelInfo): ModelInfo {
53
57
  };
54
58
  }
55
59
 
56
- function buildSolforgeEntry(base: CatalogMap): ProviderCatalogEntry | null {
57
- const solforgeModels = SOLFORGE_SOURCES.flatMap(({ id, npm }) => {
60
+ function buildSetuEntry(base: CatalogMap): ProviderCatalogEntry | null {
61
+ const setuModels = SETU_SOURCES.flatMap(({ id, npm }) => {
58
62
  const allModels = base[id]?.models ?? [];
59
63
  const sourceModels = allModels.filter((model) => {
60
64
  if (id === 'openai') return isAllowedOpenAIModel(model.id);
@@ -68,10 +72,10 @@ function buildSolforgeEntry(base: CatalogMap): ProviderCatalogEntry | null {
68
72
  });
69
73
  });
70
74
 
71
- if (!solforgeModels.length) return null;
75
+ if (!setuModels.length) return null;
72
76
 
73
77
  // Prefer OpenAI-family models first so defaults are stable
74
- solforgeModels.sort((a, b) => {
78
+ setuModels.sort((a, b) => {
75
79
  const providerA = a.provider?.npm ?? '';
76
80
  const providerB = b.provider?.npm ?? '';
77
81
  if (providerA === providerB) {
@@ -83,31 +87,31 @@ function buildSolforgeEntry(base: CatalogMap): ProviderCatalogEntry | null {
83
87
  });
84
88
 
85
89
  const defaultModelId = 'codex-mini-latest';
86
- const defaultIdx = solforgeModels.findIndex((m) => m.id === defaultModelId);
90
+ const defaultIdx = setuModels.findIndex((m) => m.id === defaultModelId);
87
91
  if (defaultIdx > 0) {
88
- const [picked] = solforgeModels.splice(defaultIdx, 1);
89
- solforgeModels.unshift(picked);
92
+ const [picked] = setuModels.splice(defaultIdx, 1);
93
+ setuModels.unshift(picked);
90
94
  }
91
95
 
92
96
  return {
93
- id: SOLFORGE_ID,
94
- label: 'Solforge',
95
- env: ['SOLFORGE_PRIVATE_KEY'],
96
- api: 'https://router.solforge.sh/v1',
97
- doc: 'https://router.solforge.sh/docs',
98
- models: solforgeModels,
97
+ id: SETU_ID,
98
+ label: 'Setu',
99
+ env: ['SETU_PRIVATE_KEY'],
100
+ api: 'https://setu.agi.nitish.sh/v1',
101
+ doc: 'https://setu.agi.nitish.sh/docs',
102
+ models: setuModels,
99
103
  };
100
104
  }
101
105
 
102
106
  export function mergeManualCatalog(
103
107
  base: CatalogMap,
104
108
  ): Record<ProviderId, ProviderCatalogEntry> {
105
- const manualEntry = buildSolforgeEntry(base);
109
+ const manualEntry = buildSetuEntry(base);
106
110
  const merged: Record<ProviderId, ProviderCatalogEntry> = {
107
111
  ...(base as Record<ProviderId, ProviderCatalogEntry>),
108
112
  };
109
113
  if (manualEntry) {
110
- merged[SOLFORGE_ID] = manualEntry;
114
+ merged[SETU_ID] = manualEntry;
111
115
  }
112
116
  return merged;
113
117
  }
@@ -6,7 +6,7 @@ const ENV_VARS: Record<ProviderId, string> = {
6
6
  google: 'GOOGLE_GENERATIVE_AI_API_KEY',
7
7
  openrouter: 'OPENROUTER_API_KEY',
8
8
  opencode: 'OPENCODE_API_KEY',
9
- solforge: 'SOLFORGE_PRIVATE_KEY',
9
+ setu: 'SETU_PRIVATE_KEY',
10
10
  zai: 'ZAI_API_KEY',
11
11
  'zai-coding': 'ZAI_API_KEY',
12
12
  moonshot: 'MOONSHOT_API_KEY',
@@ -24,19 +24,19 @@ export { validateProviderModel } from './validate.ts';
24
24
  export { estimateModelCostUsd } from './pricing.ts';
25
25
  export { providerEnvVar, readEnvKey, setEnvKey } from './env.ts';
26
26
  export {
27
- createSolforgeFetch,
28
- createSolforgeModel,
29
- fetchSolforgeBalance,
27
+ createSetuFetch,
28
+ createSetuModel,
29
+ fetchSetuBalance,
30
30
  getPublicKeyFromPrivate,
31
31
  fetchSolanaUsdcBalance,
32
- } from './solforge-client.ts';
32
+ } from './setu-client.ts';
33
33
  export type {
34
- SolforgeAuth,
35
- SolforgeProviderOptions,
36
- SolforgePaymentCallbacks,
37
- SolforgeBalanceResponse,
34
+ SetuAuth,
35
+ SetuProviderOptions,
36
+ SetuPaymentCallbacks,
37
+ SetuBalanceResponse,
38
38
  SolanaUsdcBalanceResponse,
39
- } from './solforge-client.ts';
39
+ } from './setu-client.ts';
40
40
  export {
41
41
  createOpenAIOAuthFetch,
42
42
  createOpenAIOAuthModel,
@@ -76,7 +76,7 @@ const pricingTable: Record<ProviderName, PricingEntry[]> = {
76
76
  opencode: [
77
77
  // Pricing from catalog entries; leave empty here
78
78
  ],
79
- solforge: [
79
+ setu: [
80
80
  // Pricing from catalog entries; leave empty here
81
81
  ],
82
82
  zai: [
@@ -7,6 +7,7 @@ import { svm } from 'x402/shared';
7
7
  import nacl from 'tweetnacl';
8
8
  import { createOpenAI } from '@ai-sdk/openai';
9
9
  import { createAnthropic } from '@ai-sdk/anthropic';
10
+ import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
10
11
  import { addAnthropicCacheControl } from './anthropic-caching.ts';
11
12
 
12
13
  function simplifyPaymentError(errMsg: string): string {
@@ -37,12 +38,12 @@ function simplifyPaymentError(errMsg: string): string {
37
38
  return short.length < errMsg.length ? `${short}...` : errMsg;
38
39
  }
39
40
 
40
- const DEFAULT_BASE_URL = 'https://router.solforge.sh';
41
+ const DEFAULT_BASE_URL = 'https://setu.agi.nitish.sh';
41
42
  const DEFAULT_RPC_URL = 'https://api.mainnet-beta.solana.com';
42
43
  const DEFAULT_MAX_ATTEMPTS = 3;
43
44
  const DEFAULT_MAX_PAYMENT_ATTEMPTS = 20;
44
45
 
45
- export type SolforgePaymentCallbacks = {
46
+ export type SetuPaymentCallbacks = {
46
47
  onPaymentRequired?: (amountUsd: number) => void;
47
48
  onPaymentSigning?: () => void;
48
49
  onPaymentComplete?: (data: {
@@ -53,19 +54,19 @@ export type SolforgePaymentCallbacks = {
53
54
  onPaymentError?: (error: string) => void;
54
55
  };
55
56
 
56
- export type SolforgeProviderOptions = {
57
+ export type SetuProviderOptions = {
57
58
  baseURL?: string;
58
59
  rpcURL?: string;
59
60
  network?: string;
60
61
  maxRequestAttempts?: number;
61
62
  maxPaymentAttempts?: number;
62
- callbacks?: SolforgePaymentCallbacks;
63
+ callbacks?: SetuPaymentCallbacks;
63
64
  providerNpm?: string;
64
65
  promptCacheKey?: string;
65
66
  promptCacheRetention?: 'in_memory' | '24h';
66
67
  };
67
68
 
68
- export type SolforgeAuth = {
69
+ export type SetuAuth = {
69
70
  privateKey: string;
70
71
  };
71
72
 
@@ -120,7 +121,7 @@ async function acquirePaymentLock(walletAddress: string): Promise<() => void> {
120
121
  paymentQueues.set(walletAddress, entry);
121
122
 
122
123
  if (existing) {
123
- console.log('[Solforge] Waiting for pending payment to complete...');
124
+ console.log('[Setu] Waiting for pending payment to complete...');
124
125
  await existing.promise;
125
126
  }
126
127
 
@@ -132,9 +133,9 @@ async function acquirePaymentLock(walletAddress: string): Promise<() => void> {
132
133
  };
133
134
  }
134
135
 
135
- export function createSolforgeFetch(
136
- auth: SolforgeAuth,
137
- options: SolforgeProviderOptions = {},
136
+ export function createSetuFetch(
137
+ auth: SetuAuth,
138
+ options: SetuProviderOptions = {},
138
139
  ): typeof fetch {
139
140
  const privateKeyBytes = bs58.decode(auth.privateKey);
140
141
  const keypair = Keypair.fromSecretKey(privateKeyBytes);
@@ -196,20 +197,18 @@ export function createSolforgeFetch(
196
197
  const requirement = pickPaymentRequirement(payload);
197
198
  if (!requirement) {
198
199
  callbacks.onPaymentError?.('Unsupported payment requirement');
199
- throw new Error('Solforge: unsupported payment requirement');
200
+ throw new Error('Setu: unsupported payment requirement');
200
201
  }
201
202
  if (attempt >= maxAttempts) {
202
203
  callbacks.onPaymentError?.('Payment failed after multiple attempts');
203
- throw new Error('Solforge: payment failed after multiple attempts');
204
+ throw new Error('Setu: payment failed after multiple attempts');
204
205
  }
205
206
 
206
207
  const currentAttempts = globalPaymentAttempts.get(walletAddress) ?? 0;
207
208
  const remainingPayments = maxPaymentAttempts - currentAttempts;
208
209
  if (remainingPayments <= 0) {
209
210
  callbacks.onPaymentError?.('Maximum payment attempts exceeded');
210
- throw new Error(
211
- 'Solforge: payment failed after maximum payment attempts.',
212
- );
211
+ throw new Error('Setu: payment failed after maximum payment attempts.');
213
212
  }
214
213
 
215
214
  const releaseLock = await acquirePaymentLock(walletAddress);
@@ -237,43 +236,56 @@ export function createSolforgeFetch(
237
236
  }
238
237
  }
239
238
 
240
- throw new Error('Solforge: max attempts exceeded');
239
+ throw new Error('Setu: max attempts exceeded');
241
240
  };
242
241
  }
243
242
 
244
243
  /**
245
- * Create a Solforge-backed AI model.
244
+ * Create a Setu-backed AI model.
246
245
  *
247
246
  * Uses native AI SDK providers:
248
247
  * - OpenAI models → /v1/responses (via @ai-sdk/openai)
249
248
  * - Anthropic models → /v1/messages (via @ai-sdk/anthropic)
249
+ * - Moonshot models → /v1/chat/completions (via @ai-sdk/openai-compatible)
250
250
  *
251
251
  * Provider is determined by options.providerNpm from catalog.
252
252
  */
253
- export function createSolforgeModel(
253
+ export function createSetuModel(
254
254
  model: string,
255
- auth: SolforgeAuth,
256
- options: SolforgeProviderOptions = {},
255
+ auth: SetuAuth,
256
+ options: SetuProviderOptions = {},
257
257
  ) {
258
258
  const baseURL = `${trimTrailingSlash(
259
259
  options.baseURL ?? DEFAULT_BASE_URL,
260
260
  )}/v1`;
261
- const customFetch = createSolforgeFetch(auth, options);
261
+ const customFetch = createSetuFetch(auth, options);
262
262
  const providerNpm = options.providerNpm ?? '@ai-sdk/openai';
263
263
 
264
264
  if (providerNpm === '@ai-sdk/anthropic') {
265
265
  const anthropic = createAnthropic({
266
266
  baseURL,
267
- apiKey: 'solforge-wallet-auth',
267
+ apiKey: 'setu-wallet-auth',
268
268
  fetch: customFetch,
269
269
  });
270
270
  return anthropic(model);
271
271
  }
272
272
 
273
+ if (providerNpm === '@ai-sdk/openai-compatible') {
274
+ const compatible = createOpenAICompatible({
275
+ name: 'setu-moonshot',
276
+ baseURL,
277
+ headers: {
278
+ Authorization: 'Bearer setu-wallet-auth',
279
+ },
280
+ fetch: customFetch,
281
+ });
282
+ return compatible(model);
283
+ }
284
+
273
285
  // Default to OpenAI
274
286
  const openai = createOpenAI({
275
287
  baseURL,
276
- apiKey: 'solforge-wallet-auth',
288
+ apiKey: 'setu-wallet-auth',
277
289
  fetch: customFetch,
278
290
  });
279
291
  return openai.responses(model);
@@ -314,7 +326,7 @@ async function handlePayment(args: {
314
326
  baseFetch: typeof fetch;
315
327
  buildWalletHeaders: () => Record<string, string>;
316
328
  maxAttempts: number;
317
- callbacks: SolforgePaymentCallbacks;
329
+ callbacks: SetuPaymentCallbacks;
318
330
  }): Promise<{ attemptsUsed: number }> {
319
331
  let attempts = 0;
320
332
  while (attempts < args.maxAttempts) {
@@ -334,12 +346,10 @@ async function handlePayment(args: {
334
346
  return { attemptsUsed: attempts };
335
347
  }
336
348
  console.log(
337
- `Solforge balance still negative (${balanceValue.toFixed(8)}). Sending another top-up...`,
349
+ `Setu balance still negative (${balanceValue.toFixed(8)}). Sending another top-up...`,
338
350
  );
339
351
  }
340
- throw new Error(
341
- `Solforge: payment failed after ${attempts} additional top-ups.`,
342
- );
352
+ throw new Error(`Setu: payment failed after ${attempts} additional top-ups.`);
343
353
  }
344
354
 
345
355
  async function processSinglePayment(args: {
@@ -349,7 +359,7 @@ async function processSinglePayment(args: {
349
359
  baseURL: string;
350
360
  baseFetch: typeof fetch;
351
361
  buildWalletHeaders: () => Record<string, string>;
352
- callbacks: SolforgePaymentCallbacks;
362
+ callbacks: SetuPaymentCallbacks;
353
363
  }): Promise<{ attempts: number; balance?: number | string }> {
354
364
  args.callbacks.onPaymentSigning?.();
355
365
 
@@ -360,7 +370,7 @@ async function processSinglePayment(args: {
360
370
  const errMsg = err instanceof Error ? err.message : String(err);
361
371
  const userMsg = `Payment failed: ${simplifyPaymentError(errMsg)}`;
362
372
  args.callbacks.onPaymentError?.(userMsg);
363
- throw new Error(`Solforge: ${userMsg}`);
373
+ throw new Error(`Setu: ${userMsg}`);
364
374
  }
365
375
  const walletHeaders = args.buildWalletHeaders();
366
376
  const headers = {
@@ -382,11 +392,11 @@ async function processSinglePayment(args: {
382
392
  response.status === 400 &&
383
393
  rawBody.toLowerCase().includes('already processed')
384
394
  ) {
385
- console.log('Solforge payment already processed; continuing.');
395
+ console.log('Setu payment already processed; continuing.');
386
396
  return { attempts: 1 };
387
397
  }
388
398
  args.callbacks.onPaymentError?.(`Topup failed: ${response.status}`);
389
- throw new Error(`Solforge topup failed (${response.status}): ${rawBody}`);
399
+ throw new Error(`Setu topup failed (${response.status}): ${rawBody}`);
390
400
  }
391
401
 
392
402
  let parsed: PaymentResponse | undefined;
@@ -411,11 +421,11 @@ async function processSinglePayment(args: {
411
421
  transactionId: parsed.transaction,
412
422
  });
413
423
  console.log(
414
- `Solforge payment complete: +$${amountUsd} (balance: $${newBalance})`,
424
+ `Setu payment complete: +$${amountUsd} (balance: $${newBalance})`,
415
425
  );
416
426
  return { attempts: 1, balance: newBalance };
417
427
  }
418
- console.log('Solforge payment complete.');
428
+ console.log('Setu payment complete.');
419
429
  return { attempts: 1 };
420
430
  }
421
431
 
@@ -452,7 +462,7 @@ async function createPaymentPayload(args: {
452
462
  } as PaymentPayload;
453
463
  }
454
464
 
455
- export type SolforgeBalanceResponse = {
465
+ export type SetuBalanceResponse = {
456
466
  walletAddress: string;
457
467
  balance: number;
458
468
  totalSpent: number;
@@ -462,10 +472,10 @@ export type SolforgeBalanceResponse = {
462
472
  lastRequest?: string;
463
473
  };
464
474
 
465
- export async function fetchSolforgeBalance(
466
- auth: SolforgeAuth,
475
+ export async function fetchSetuBalance(
476
+ auth: SetuAuth,
467
477
  baseURL?: string,
468
- ): Promise<SolforgeBalanceResponse | null> {
478
+ ): Promise<SetuBalanceResponse | null> {
469
479
  try {
470
480
  const privateKeyBytes = bs58.decode(auth.privateKey);
471
481
  const keypair = Keypair.fromSecretKey(privateKeyBytes);
@@ -531,7 +541,7 @@ export type SolanaUsdcBalanceResponse = {
531
541
  };
532
542
 
533
543
  export async function fetchSolanaUsdcBalance(
534
- auth: SolforgeAuth,
544
+ auth: SetuAuth,
535
545
  network: 'mainnet' | 'devnet' = 'mainnet',
536
546
  ): Promise<SolanaUsdcBalanceResponse | null> {
537
547
  try {
@@ -42,7 +42,7 @@ const PREFERRED_FAST_MODELS: Partial<Record<ProviderId, string[]>> = {
42
42
  'google/gemini-2.0-flash-001',
43
43
  ],
44
44
  opencode: ['claude-3-5-haiku', 'gpt-5-nano', 'gemini-3-flash'],
45
- solforge: [
45
+ setu: [
46
46
  'claude-3-5-haiku-latest',
47
47
  'claude-3-5-haiku-20241022',
48
48
  'codex-mini-latest',
@@ -7,7 +7,7 @@ export type ProviderId =
7
7
  | 'google'
8
8
  | 'openrouter'
9
9
  | 'opencode'
10
- | 'solforge'
10
+ | 'setu'
11
11
  | 'zai'
12
12
  | 'zai-coding'
13
13
  | 'moonshot';