@agi-cli/sdk 0.1.141 → 0.1.142

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.142",
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',
@@ -53,8 +53,8 @@ function cloneModel(model: ModelInfo): ModelInfo {
53
53
  };
54
54
  }
55
55
 
56
- function buildSolforgeEntry(base: CatalogMap): ProviderCatalogEntry | null {
57
- const solforgeModels = SOLFORGE_SOURCES.flatMap(({ id, npm }) => {
56
+ function buildSetuEntry(base: CatalogMap): ProviderCatalogEntry | null {
57
+ const setuModels = SETU_SOURCES.flatMap(({ id, npm }) => {
58
58
  const allModels = base[id]?.models ?? [];
59
59
  const sourceModels = allModels.filter((model) => {
60
60
  if (id === 'openai') return isAllowedOpenAIModel(model.id);
@@ -68,10 +68,10 @@ function buildSolforgeEntry(base: CatalogMap): ProviderCatalogEntry | null {
68
68
  });
69
69
  });
70
70
 
71
- if (!solforgeModels.length) return null;
71
+ if (!setuModels.length) return null;
72
72
 
73
73
  // Prefer OpenAI-family models first so defaults are stable
74
- solforgeModels.sort((a, b) => {
74
+ setuModels.sort((a, b) => {
75
75
  const providerA = a.provider?.npm ?? '';
76
76
  const providerB = b.provider?.npm ?? '';
77
77
  if (providerA === providerB) {
@@ -83,31 +83,31 @@ function buildSolforgeEntry(base: CatalogMap): ProviderCatalogEntry | null {
83
83
  });
84
84
 
85
85
  const defaultModelId = 'codex-mini-latest';
86
- const defaultIdx = solforgeModels.findIndex((m) => m.id === defaultModelId);
86
+ const defaultIdx = setuModels.findIndex((m) => m.id === defaultModelId);
87
87
  if (defaultIdx > 0) {
88
- const [picked] = solforgeModels.splice(defaultIdx, 1);
89
- solforgeModels.unshift(picked);
88
+ const [picked] = setuModels.splice(defaultIdx, 1);
89
+ setuModels.unshift(picked);
90
90
  }
91
91
 
92
92
  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,
93
+ id: SETU_ID,
94
+ label: 'Setu',
95
+ env: ['SETU_PRIVATE_KEY'],
96
+ api: 'https://setu.agi.nitish.sh/v1',
97
+ doc: 'https://setu.agi.nitish.sh/docs',
98
+ models: setuModels,
99
99
  };
100
100
  }
101
101
 
102
102
  export function mergeManualCatalog(
103
103
  base: CatalogMap,
104
104
  ): Record<ProviderId, ProviderCatalogEntry> {
105
- const manualEntry = buildSolforgeEntry(base);
105
+ const manualEntry = buildSetuEntry(base);
106
106
  const merged: Record<ProviderId, ProviderCatalogEntry> = {
107
107
  ...(base as Record<ProviderId, ProviderCatalogEntry>),
108
108
  };
109
109
  if (manualEntry) {
110
- merged[SOLFORGE_ID] = manualEntry;
110
+ merged[SETU_ID] = manualEntry;
111
111
  }
112
112
  return merged;
113
113
  }
@@ -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: [
@@ -37,12 +37,12 @@ function simplifyPaymentError(errMsg: string): string {
37
37
  return short.length < errMsg.length ? `${short}...` : errMsg;
38
38
  }
39
39
 
40
- const DEFAULT_BASE_URL = 'https://router.solforge.sh';
40
+ const DEFAULT_BASE_URL = 'https://setu.agi.nitish.sh';
41
41
  const DEFAULT_RPC_URL = 'https://api.mainnet-beta.solana.com';
42
42
  const DEFAULT_MAX_ATTEMPTS = 3;
43
43
  const DEFAULT_MAX_PAYMENT_ATTEMPTS = 20;
44
44
 
45
- export type SolforgePaymentCallbacks = {
45
+ export type SetuPaymentCallbacks = {
46
46
  onPaymentRequired?: (amountUsd: number) => void;
47
47
  onPaymentSigning?: () => void;
48
48
  onPaymentComplete?: (data: {
@@ -53,19 +53,19 @@ export type SolforgePaymentCallbacks = {
53
53
  onPaymentError?: (error: string) => void;
54
54
  };
55
55
 
56
- export type SolforgeProviderOptions = {
56
+ export type SetuProviderOptions = {
57
57
  baseURL?: string;
58
58
  rpcURL?: string;
59
59
  network?: string;
60
60
  maxRequestAttempts?: number;
61
61
  maxPaymentAttempts?: number;
62
- callbacks?: SolforgePaymentCallbacks;
62
+ callbacks?: SetuPaymentCallbacks;
63
63
  providerNpm?: string;
64
64
  promptCacheKey?: string;
65
65
  promptCacheRetention?: 'in_memory' | '24h';
66
66
  };
67
67
 
68
- export type SolforgeAuth = {
68
+ export type SetuAuth = {
69
69
  privateKey: string;
70
70
  };
71
71
 
@@ -120,7 +120,7 @@ async function acquirePaymentLock(walletAddress: string): Promise<() => void> {
120
120
  paymentQueues.set(walletAddress, entry);
121
121
 
122
122
  if (existing) {
123
- console.log('[Solforge] Waiting for pending payment to complete...');
123
+ console.log('[Setu] Waiting for pending payment to complete...');
124
124
  await existing.promise;
125
125
  }
126
126
 
@@ -132,9 +132,9 @@ async function acquirePaymentLock(walletAddress: string): Promise<() => void> {
132
132
  };
133
133
  }
134
134
 
135
- export function createSolforgeFetch(
136
- auth: SolforgeAuth,
137
- options: SolforgeProviderOptions = {},
135
+ export function createSetuFetch(
136
+ auth: SetuAuth,
137
+ options: SetuProviderOptions = {},
138
138
  ): typeof fetch {
139
139
  const privateKeyBytes = bs58.decode(auth.privateKey);
140
140
  const keypair = Keypair.fromSecretKey(privateKeyBytes);
@@ -196,20 +196,18 @@ export function createSolforgeFetch(
196
196
  const requirement = pickPaymentRequirement(payload);
197
197
  if (!requirement) {
198
198
  callbacks.onPaymentError?.('Unsupported payment requirement');
199
- throw new Error('Solforge: unsupported payment requirement');
199
+ throw new Error('Setu: unsupported payment requirement');
200
200
  }
201
201
  if (attempt >= maxAttempts) {
202
202
  callbacks.onPaymentError?.('Payment failed after multiple attempts');
203
- throw new Error('Solforge: payment failed after multiple attempts');
203
+ throw new Error('Setu: payment failed after multiple attempts');
204
204
  }
205
205
 
206
206
  const currentAttempts = globalPaymentAttempts.get(walletAddress) ?? 0;
207
207
  const remainingPayments = maxPaymentAttempts - currentAttempts;
208
208
  if (remainingPayments <= 0) {
209
209
  callbacks.onPaymentError?.('Maximum payment attempts exceeded');
210
- throw new Error(
211
- 'Solforge: payment failed after maximum payment attempts.',
212
- );
210
+ throw new Error('Setu: payment failed after maximum payment attempts.');
213
211
  }
214
212
 
215
213
  const releaseLock = await acquirePaymentLock(walletAddress);
@@ -237,12 +235,12 @@ export function createSolforgeFetch(
237
235
  }
238
236
  }
239
237
 
240
- throw new Error('Solforge: max attempts exceeded');
238
+ throw new Error('Setu: max attempts exceeded');
241
239
  };
242
240
  }
243
241
 
244
242
  /**
245
- * Create a Solforge-backed AI model.
243
+ * Create a Setu-backed AI model.
246
244
  *
247
245
  * Uses native AI SDK providers:
248
246
  * - OpenAI models → /v1/responses (via @ai-sdk/openai)
@@ -250,21 +248,21 @@ export function createSolforgeFetch(
250
248
  *
251
249
  * Provider is determined by options.providerNpm from catalog.
252
250
  */
253
- export function createSolforgeModel(
251
+ export function createSetuModel(
254
252
  model: string,
255
- auth: SolforgeAuth,
256
- options: SolforgeProviderOptions = {},
253
+ auth: SetuAuth,
254
+ options: SetuProviderOptions = {},
257
255
  ) {
258
256
  const baseURL = `${trimTrailingSlash(
259
257
  options.baseURL ?? DEFAULT_BASE_URL,
260
258
  )}/v1`;
261
- const customFetch = createSolforgeFetch(auth, options);
259
+ const customFetch = createSetuFetch(auth, options);
262
260
  const providerNpm = options.providerNpm ?? '@ai-sdk/openai';
263
261
 
264
262
  if (providerNpm === '@ai-sdk/anthropic') {
265
263
  const anthropic = createAnthropic({
266
264
  baseURL,
267
- apiKey: 'solforge-wallet-auth',
265
+ apiKey: 'setu-wallet-auth',
268
266
  fetch: customFetch,
269
267
  });
270
268
  return anthropic(model);
@@ -273,7 +271,7 @@ export function createSolforgeModel(
273
271
  // Default to OpenAI
274
272
  const openai = createOpenAI({
275
273
  baseURL,
276
- apiKey: 'solforge-wallet-auth',
274
+ apiKey: 'setu-wallet-auth',
277
275
  fetch: customFetch,
278
276
  });
279
277
  return openai.responses(model);
@@ -314,7 +312,7 @@ async function handlePayment(args: {
314
312
  baseFetch: typeof fetch;
315
313
  buildWalletHeaders: () => Record<string, string>;
316
314
  maxAttempts: number;
317
- callbacks: SolforgePaymentCallbacks;
315
+ callbacks: SetuPaymentCallbacks;
318
316
  }): Promise<{ attemptsUsed: number }> {
319
317
  let attempts = 0;
320
318
  while (attempts < args.maxAttempts) {
@@ -334,12 +332,10 @@ async function handlePayment(args: {
334
332
  return { attemptsUsed: attempts };
335
333
  }
336
334
  console.log(
337
- `Solforge balance still negative (${balanceValue.toFixed(8)}). Sending another top-up...`,
335
+ `Setu balance still negative (${balanceValue.toFixed(8)}). Sending another top-up...`,
338
336
  );
339
337
  }
340
- throw new Error(
341
- `Solforge: payment failed after ${attempts} additional top-ups.`,
342
- );
338
+ throw new Error(`Setu: payment failed after ${attempts} additional top-ups.`);
343
339
  }
344
340
 
345
341
  async function processSinglePayment(args: {
@@ -349,7 +345,7 @@ async function processSinglePayment(args: {
349
345
  baseURL: string;
350
346
  baseFetch: typeof fetch;
351
347
  buildWalletHeaders: () => Record<string, string>;
352
- callbacks: SolforgePaymentCallbacks;
348
+ callbacks: SetuPaymentCallbacks;
353
349
  }): Promise<{ attempts: number; balance?: number | string }> {
354
350
  args.callbacks.onPaymentSigning?.();
355
351
 
@@ -360,7 +356,7 @@ async function processSinglePayment(args: {
360
356
  const errMsg = err instanceof Error ? err.message : String(err);
361
357
  const userMsg = `Payment failed: ${simplifyPaymentError(errMsg)}`;
362
358
  args.callbacks.onPaymentError?.(userMsg);
363
- throw new Error(`Solforge: ${userMsg}`);
359
+ throw new Error(`Setu: ${userMsg}`);
364
360
  }
365
361
  const walletHeaders = args.buildWalletHeaders();
366
362
  const headers = {
@@ -382,11 +378,11 @@ async function processSinglePayment(args: {
382
378
  response.status === 400 &&
383
379
  rawBody.toLowerCase().includes('already processed')
384
380
  ) {
385
- console.log('Solforge payment already processed; continuing.');
381
+ console.log('Setu payment already processed; continuing.');
386
382
  return { attempts: 1 };
387
383
  }
388
384
  args.callbacks.onPaymentError?.(`Topup failed: ${response.status}`);
389
- throw new Error(`Solforge topup failed (${response.status}): ${rawBody}`);
385
+ throw new Error(`Setu topup failed (${response.status}): ${rawBody}`);
390
386
  }
391
387
 
392
388
  let parsed: PaymentResponse | undefined;
@@ -411,11 +407,11 @@ async function processSinglePayment(args: {
411
407
  transactionId: parsed.transaction,
412
408
  });
413
409
  console.log(
414
- `Solforge payment complete: +$${amountUsd} (balance: $${newBalance})`,
410
+ `Setu payment complete: +$${amountUsd} (balance: $${newBalance})`,
415
411
  );
416
412
  return { attempts: 1, balance: newBalance };
417
413
  }
418
- console.log('Solforge payment complete.');
414
+ console.log('Setu payment complete.');
419
415
  return { attempts: 1 };
420
416
  }
421
417
 
@@ -452,7 +448,7 @@ async function createPaymentPayload(args: {
452
448
  } as PaymentPayload;
453
449
  }
454
450
 
455
- export type SolforgeBalanceResponse = {
451
+ export type SetuBalanceResponse = {
456
452
  walletAddress: string;
457
453
  balance: number;
458
454
  totalSpent: number;
@@ -462,10 +458,10 @@ export type SolforgeBalanceResponse = {
462
458
  lastRequest?: string;
463
459
  };
464
460
 
465
- export async function fetchSolforgeBalance(
466
- auth: SolforgeAuth,
461
+ export async function fetchSetuBalance(
462
+ auth: SetuAuth,
467
463
  baseURL?: string,
468
- ): Promise<SolforgeBalanceResponse | null> {
464
+ ): Promise<SetuBalanceResponse | null> {
469
465
  try {
470
466
  const privateKeyBytes = bs58.decode(auth.privateKey);
471
467
  const keypair = Keypair.fromSecretKey(privateKeyBytes);
@@ -531,7 +527,7 @@ export type SolanaUsdcBalanceResponse = {
531
527
  };
532
528
 
533
529
  export async function fetchSolanaUsdcBalance(
534
- auth: SolforgeAuth,
530
+ auth: SetuAuth,
535
531
  network: 'mainnet' | 'devnet' = 'mainnet',
536
532
  ): Promise<SolanaUsdcBalanceResponse | null> {
537
533
  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';