@ottocode/ai-sdk 0.1.2 → 0.1.4

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/src/index.ts CHANGED
@@ -28,8 +28,12 @@ export { createSetuFetch } from './fetch.ts';
28
28
  export type { CreateSetuFetchOptions } from './fetch.ts';
29
29
 
30
30
  export { fetchBalance, fetchWalletUsdcBalance } from './balance.ts';
31
- export { getPublicKeyFromPrivate } from './auth.ts';
31
+ export { getPublicKeyFromPrivate, createWalletContext } from './auth.ts';
32
+ export type { WalletContext } from './auth.ts';
32
33
  export { addAnthropicCacheControl } from './cache.ts';
33
34
 
34
35
  export { generateWallet, importWallet, isValidPrivateKey } from './wallet.ts';
35
36
  export type { WalletInfo } from './wallet.ts';
37
+
38
+ export { setuCatalog } from './catalog.ts';
39
+ export type { SetuModelCatalogEntry, SetuCatalog } from './catalog.ts';
package/src/setu.ts CHANGED
@@ -27,7 +27,12 @@ export interface SetuInstance {
27
27
 
28
28
  export function createSetu(config: SetuConfig): SetuInstance {
29
29
  const baseURL = trimTrailingSlash(config.baseURL ?? DEFAULT_BASE_URL);
30
- const wallet = createWalletContext(config.auth);
30
+ const privateKey = config.auth.privateKey || process.env.SETU_PRIVATE_KEY;
31
+ if (!privateKey) {
32
+ throw new Error('Setu: privateKey is required. Pass it via config.auth.privateKey or set SETU_PRIVATE_KEY env variable.');
33
+ }
34
+ const resolvedAuth = { ...config.auth, privateKey };
35
+ const wallet = createWalletContext(resolvedAuth);
31
36
  const registry = new ProviderRegistry(config.providers, config.modelMap);
32
37
 
33
38
  const setuFetch = createSetuFetch({
@@ -74,14 +79,14 @@ export function createSetu(config: SetuConfig): SetuInstance {
74
79
  },
75
80
 
76
81
  async balance() {
77
- return fetchBalance(config.auth, baseURL);
82
+ return fetchBalance(resolvedAuth, baseURL);
78
83
  },
79
84
 
80
85
  async walletBalance(network?: 'mainnet' | 'devnet') {
81
- return fetchWalletUsdcBalance(config.auth, network);
86
+ return fetchWalletUsdcBalance(resolvedAuth, network);
82
87
  },
83
88
 
84
- walletAddress: getPublicKeyFromPrivate(config.auth.privateKey),
89
+ walletAddress: getPublicKeyFromPrivate(resolvedAuth.privateKey),
85
90
 
86
91
  registry,
87
92
  };
package/src/types.ts CHANGED
@@ -21,7 +21,7 @@ export interface ProviderConfig {
21
21
  }
22
22
 
23
23
  export interface SetuAuth {
24
- privateKey: string;
24
+ privateKey?: string;
25
25
  }
26
26
 
27
27
  export interface BalanceUpdate {