@ottocode/sdk 0.1.244 → 0.1.245

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@ottocode/sdk",
3
- "version": "0.1.244",
3
+ "version": "0.1.245",
4
4
  "description": "AI agent SDK for building intelligent assistants - tree-shakable and comprehensive",
5
5
  "author": "nitishxyz",
6
6
  "license": "MIT",
@@ -97,7 +97,7 @@
97
97
  "@modelcontextprotocol/sdk": "^1.12",
98
98
  "@openauthjs/openauth": "^0.4.3",
99
99
  "@openrouter/ai-sdk-provider": "^1.2.0",
100
- "@ottocode/ai-sdk": "0.2.0",
100
+ "@ottorouter/ai-sdk": "0.2.0",
101
101
  "@solana/web3.js": "^1.98.0",
102
102
  "ai": "^6.0.0",
103
103
  "bs58": "^6.0.0",
@@ -86,8 +86,8 @@ export {
86
86
  generateWallet,
87
87
  importWallet,
88
88
  isValidPrivateKey,
89
- getSetuWallet,
90
- ensureSetuWallet,
89
+ getOttoRouterWallet,
90
+ ensureOttoRouterWallet,
91
91
  type WalletInfo,
92
92
  } from './wallet.ts';
93
93
 
@@ -34,25 +34,25 @@ export function isValidPrivateKey(privateKey: string): boolean {
34
34
  }
35
35
  }
36
36
 
37
- export async function getSetuWallet(
37
+ export async function getOttoRouterWallet(
38
38
  projectRoot?: string,
39
39
  ): Promise<WalletInfo | null> {
40
- const auth = await getAuth('setu', projectRoot);
40
+ const auth = await getAuth('ottorouter', projectRoot);
41
41
  if (auth?.type === 'wallet' && auth.secret) {
42
42
  return importWallet(auth.secret);
43
43
  }
44
44
  return null;
45
45
  }
46
46
 
47
- export async function ensureSetuWallet(
47
+ export async function ensureOttoRouterWallet(
48
48
  projectRoot?: string,
49
49
  ): Promise<WalletInfo> {
50
- const existing = await getSetuWallet(projectRoot);
50
+ const existing = await getOttoRouterWallet(projectRoot);
51
51
  if (existing) return existing;
52
52
 
53
53
  const wallet = generateWallet();
54
54
  await setAuth(
55
- 'setu',
55
+ 'ottorouter',
56
56
  { type: 'wallet', secret: wallet.privateKey },
57
57
  projectRoot,
58
58
  'global',
@@ -16,7 +16,7 @@ const DEFAULT_PROVIDER_SETTINGS: OttoConfig['providers'] = {
16
16
  openrouter: { enabled: false },
17
17
  opencode: { enabled: false },
18
18
  copilot: { enabled: false },
19
- setu: { enabled: true },
19
+ ottorouter: { enabled: true },
20
20
  zai: { enabled: false },
21
21
  'zai-coding': { enabled: false },
22
22
  moonshot: { enabled: false },
@@ -29,7 +29,7 @@ const DEFAULTS: {
29
29
  } = {
30
30
  defaults: {
31
31
  agent: 'build',
32
- provider: 'setu',
32
+ provider: 'ottorouter',
33
33
  model: 'kimi-k2.5',
34
34
  toolApproval: 'auto',
35
35
  guidedMode: false,
@@ -105,7 +105,12 @@ export {
105
105
  // Logging & Debug
106
106
  // =======================
107
107
  export { logger, debug, info, warn, error, time } from './utils/logger.ts';
108
- export { isDebugEnabled, isTraceEnabled } from './utils/debug.ts';
108
+ export {
109
+ isDebugEnabled,
110
+ isTraceEnabled,
111
+ setDebugEnabled,
112
+ setTraceEnabled,
113
+ } from './utils/debug.ts';
109
114
 
110
115
  // =======================
111
116
  // MCP (Model Context Protocol)
@@ -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
- createSetuModel,
8
+ createOttoRouterModel,
9
9
  createOpenAIOAuthModel,
10
10
  } from '../../../providers/src/index.ts';
11
11
  import { createCopilotModel } from '../../../providers/src/copilot-client.ts';
@@ -35,7 +35,7 @@ export type ProviderName =
35
35
  | 'openrouter'
36
36
  | 'opencode'
37
37
  | 'copilot'
38
- | 'setu'
38
+ | 'ottorouter'
39
39
  | 'zai'
40
40
  | 'zai-coding'
41
41
  | 'moonshot';
@@ -163,16 +163,17 @@ export async function resolveModel(
163
163
  );
164
164
  }
165
165
 
166
- if (provider === 'setu') {
167
- const privateKey = config.apiKey || process.env.SETU_PRIVATE_KEY || '';
166
+ if (provider === 'ottorouter') {
167
+ const privateKey =
168
+ config.apiKey || process.env.OTTOROUTER_PRIVATE_KEY || '';
168
169
  if (!privateKey) {
169
170
  throw new Error(
170
- 'Setu provider requires SETU_PRIVATE_KEY (base58 Solana secret).',
171
+ 'OttoRouter provider requires OTTOROUTER_PRIVATE_KEY (base58 Solana secret).',
171
172
  );
172
173
  }
173
- const baseURL = config.baseURL || process.env.SETU_BASE_URL;
174
- const rpcURL = process.env.SETU_SOLANA_RPC_URL;
175
- return createSetuModel(
174
+ const baseURL = config.baseURL || process.env.OTTOROUTER_BASE_URL;
175
+ const rpcURL = process.env.OTTOROUTER_SOLANA_RPC_URL;
176
+ return createOttoRouterModel(
176
177
  model,
177
178
  { privateKey },
178
179
  {
@@ -6,6 +6,9 @@ type DebugSettings = {
6
6
  debugScopes?: unknown;
7
7
  };
8
8
 
9
+ let debugEnabledOverride: boolean | undefined;
10
+ let traceEnabledOverride: boolean | undefined;
11
+
9
12
  function readDebugSettings(): DebugSettings {
10
13
  try {
11
14
  const raw = readFileSync(getGlobalConfigPath(), 'utf-8');
@@ -17,13 +20,23 @@ function readDebugSettings(): DebugSettings {
17
20
  }
18
21
 
19
22
  export function isDebugEnabled(): boolean {
23
+ if (debugEnabledOverride !== undefined) return debugEnabledOverride;
20
24
  return readDebugSettings().debugEnabled === true;
21
25
  }
22
26
 
23
27
  export function isTraceEnabled(): boolean {
28
+ if (traceEnabledOverride !== undefined) return traceEnabledOverride;
24
29
  return false;
25
30
  }
26
31
 
32
+ export function setDebugEnabled(enabled: boolean): void {
33
+ debugEnabledOverride = enabled;
34
+ }
35
+
36
+ export function setTraceEnabled(enabled: boolean): void {
37
+ traceEnabledOverride = enabled;
38
+ }
39
+
27
40
  export function getDebugScopes(): string[] {
28
41
  const scopes = readDebugSettings().debugScopes;
29
42
  if (!Array.isArray(scopes)) return [];
package/src/index.ts CHANGED
@@ -63,20 +63,20 @@ export {
63
63
  setEnvKey,
64
64
  } from './providers/src/index.ts';
65
65
  export {
66
- createSetu,
67
- createSetuFetch,
68
- createSetuModel,
69
- fetchSetuBalance,
66
+ createOttoRouter,
67
+ createOttoRouterFetch,
68
+ createOttoRouterModel,
69
+ fetchOttoRouterBalance,
70
70
  getPublicKeyFromPrivate,
71
71
  fetchSolanaUsdcBalance,
72
72
  } from './providers/src/index.ts';
73
73
  export type {
74
- SetuAuth,
75
- SetuInstance,
76
- SetuProviderOptions,
77
- SetuPaymentCallbacks,
78
- SetuBalanceUpdate,
79
- SetuBalanceResponse,
74
+ OttoRouterAuth,
75
+ OttoRouterInstance,
76
+ OttoRouterProviderOptions,
77
+ OttoRouterPaymentCallbacks,
78
+ OttoRouterBalanceUpdate,
79
+ OttoRouterBalanceResponse,
80
80
  SolanaUsdcBalanceResponse,
81
81
  } from './providers/src/index.ts';
82
82
  export {
@@ -150,8 +150,8 @@ export {
150
150
  generateWallet,
151
151
  importWallet,
152
152
  isValidPrivateKey,
153
- getSetuWallet,
154
- ensureSetuWallet,
153
+ getOttoRouterWallet,
154
+ ensureOttoRouterWallet,
155
155
  } from './auth/src/index.ts';
156
156
  export type { WalletInfo } from './auth/src/index.ts';
157
157
  export {
@@ -290,6 +290,8 @@ export {
290
290
  time,
291
291
  isDebugEnabled,
292
292
  isTraceEnabled,
293
+ setDebugEnabled,
294
+ setTraceEnabled,
293
295
  } from './core/src/index.ts';
294
296
 
295
297
  // Schema Validation
@@ -1,4 +1,7 @@
1
- import { setuCatalog, type SetuModelCatalogEntry } from '@ottocode/ai-sdk';
1
+ import {
2
+ ottorouterCatalog,
3
+ type OttoRouterModelCatalogEntry,
4
+ } from '@ottorouter/ai-sdk';
2
5
  import type {
3
6
  ModelInfo,
4
7
  ModelOwner,
@@ -8,7 +11,7 @@ import type {
8
11
 
9
12
  type CatalogMap = Partial<Record<ProviderId, ProviderCatalogEntry>>;
10
13
 
11
- const SETU_ID: ProviderId = 'setu';
14
+ const OTTOROUTER_ID: ProviderId = 'ottorouter';
12
15
 
13
16
  const OWNER_NPM: Record<ModelOwner, string> = {
14
17
  openai: '@ai-sdk/openai',
@@ -21,7 +24,7 @@ const OWNER_NPM: Record<ModelOwner, string> = {
21
24
  minimax: '@ai-sdk/anthropic',
22
25
  };
23
26
 
24
- function convertSetuModel(m: SetuModelCatalogEntry): ModelInfo {
27
+ function convertOttoRouterModel(m: OttoRouterModelCatalogEntry): ModelInfo {
25
28
  const ownedBy = m.owned_by as ModelOwner;
26
29
  return {
27
30
  id: m.id,
@@ -52,12 +55,12 @@ function convertSetuModel(m: SetuModelCatalogEntry): ModelInfo {
52
55
  };
53
56
  }
54
57
 
55
- function buildSetuEntry(): ProviderCatalogEntry | null {
56
- const setuModels = setuCatalog.models.map(convertSetuModel);
58
+ function buildOttoRouterEntry(): ProviderCatalogEntry | null {
59
+ const ottorouterModels = ottorouterCatalog.models.map(convertOttoRouterModel);
57
60
 
58
- if (!setuModels.length) return null;
61
+ if (!ottorouterModels.length) return null;
59
62
 
60
- setuModels.sort((a, b) => {
63
+ ottorouterModels.sort((a, b) => {
61
64
  const ownerA = a.ownedBy ?? '';
62
65
  const ownerB = b.ownedBy ?? '';
63
66
  if (ownerA === ownerB) {
@@ -69,31 +72,31 @@ function buildSetuEntry(): ProviderCatalogEntry | null {
69
72
  });
70
73
 
71
74
  const defaultModelId = 'gpt-5-codex';
72
- const defaultIdx = setuModels.findIndex((m) => m.id === defaultModelId);
75
+ const defaultIdx = ottorouterModels.findIndex((m) => m.id === defaultModelId);
73
76
  if (defaultIdx > 0) {
74
- const [picked] = setuModels.splice(defaultIdx, 1);
75
- setuModels.unshift(picked);
77
+ const [picked] = ottorouterModels.splice(defaultIdx, 1);
78
+ ottorouterModels.unshift(picked);
76
79
  }
77
80
 
78
81
  return {
79
- id: SETU_ID,
80
- label: 'Setu',
81
- env: ['SETU_PRIVATE_KEY'],
82
- api: 'https://setu.ottocode.io/v1',
83
- doc: 'https://setu.ottocode.io/docs',
84
- models: setuModels,
82
+ id: OTTOROUTER_ID,
83
+ label: 'OttoRouter',
84
+ env: ['OTTOROUTER_PRIVATE_KEY'],
85
+ api: 'https://api.ottorouter.org/v1',
86
+ doc: 'https://ottorouter.org/docs',
87
+ models: ottorouterModels,
85
88
  };
86
89
  }
87
90
 
88
91
  export function mergeManualCatalog(
89
92
  base: CatalogMap,
90
93
  ): Record<ProviderId, ProviderCatalogEntry> {
91
- const manualEntry = buildSetuEntry();
94
+ const manualEntry = buildOttoRouterEntry();
92
95
  const merged: Record<ProviderId, ProviderCatalogEntry> = {
93
96
  ...(base as Record<ProviderId, ProviderCatalogEntry>),
94
97
  };
95
98
  if (manualEntry) {
96
- merged[SETU_ID] = manualEntry;
99
+ merged[OTTOROUTER_ID] = manualEntry;
97
100
  }
98
101
  return merged;
99
102
  }
@@ -2060,7 +2060,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
2060
2060
  cost: {
2061
2061
  input: 0.3,
2062
2062
  output: 2.5,
2063
- cacheRead: 0.075,
2063
+ cacheRead: 0.03,
2064
2064
  },
2065
2065
  limit: {
2066
2066
  context: 1048576,
@@ -7,7 +7,7 @@ const ENV_VARS: Record<ProviderId, string> = {
7
7
  openrouter: 'OPENROUTER_API_KEY',
8
8
  opencode: 'OPENCODE_API_KEY',
9
9
  copilot: 'GITHUB_TOKEN',
10
- setu: 'SETU_PRIVATE_KEY',
10
+ ottorouter: 'OTTOROUTER_PRIVATE_KEY',
11
11
  zai: 'ZAI_API_KEY',
12
12
  'zai-coding': 'ZAI_CODING_API_KEY',
13
13
  moonshot: 'MOONSHOT_API_KEY',
@@ -25,22 +25,22 @@ export { validateProviderModel } from './validate.ts';
25
25
  export { estimateModelCostUsd } from './pricing.ts';
26
26
  export { providerEnvVar, readEnvKey, setEnvKey } from './env.ts';
27
27
  export {
28
- createSetu,
29
- createSetuFetch,
30
- createSetuModel,
31
- fetchSetuBalance,
28
+ createOttoRouter,
29
+ createOttoRouterFetch,
30
+ createOttoRouterModel,
31
+ fetchOttoRouterBalance,
32
32
  getPublicKeyFromPrivate,
33
33
  fetchSolanaUsdcBalance,
34
- } from './setu-client.ts';
34
+ } from './ottorouter-client.ts';
35
35
  export type {
36
- SetuAuth,
37
- SetuInstance,
38
- SetuProviderOptions,
39
- SetuPaymentCallbacks,
40
- SetuBalanceUpdate,
41
- SetuBalanceResponse,
36
+ OttoRouterAuth,
37
+ OttoRouterInstance,
38
+ OttoRouterProviderOptions,
39
+ OttoRouterPaymentCallbacks,
40
+ OttoRouterBalanceUpdate,
41
+ OttoRouterBalanceResponse,
42
42
  SolanaUsdcBalanceResponse,
43
- } from './setu-client.ts';
43
+ } from './ottorouter-client.ts';
44
44
  export {
45
45
  createOpenAIOAuthFetch,
46
46
  createOpenAIOAuthModel,
@@ -1,29 +1,29 @@
1
1
  import {
2
- createSetu,
2
+ createOttoRouter,
3
3
  fetchBalance,
4
4
  fetchWalletUsdcBalance,
5
5
  getPublicKeyFromPrivate as _getPublicKeyFromPrivate,
6
- type SetuConfig,
6
+ type OttoRouterConfig,
7
7
  type PaymentCallbacks,
8
8
  type BalanceUpdate,
9
9
  type BalanceResponse,
10
10
  type WalletUsdcBalance,
11
- type SetuAuth as _SetuAuth,
12
- type SetuInstance,
13
- } from '@ottocode/ai-sdk';
11
+ type OttoRouterAuth as _OttoRouterAuth,
12
+ type OttoRouterInstance,
13
+ } from '@ottorouter/ai-sdk';
14
14
  import type { LanguageModelV3Middleware } from '@ai-sdk/provider';
15
15
 
16
- export type SetuBalanceUpdate = BalanceUpdate;
16
+ export type OttoRouterBalanceUpdate = BalanceUpdate;
17
17
 
18
- export type SetuPaymentCallbacks = PaymentCallbacks;
18
+ export type OttoRouterPaymentCallbacks = PaymentCallbacks;
19
19
 
20
- export type SetuProviderOptions = {
20
+ export type OttoRouterProviderOptions = {
21
21
  baseURL?: string;
22
22
  rpcURL?: string;
23
23
  network?: string;
24
24
  maxRequestAttempts?: number;
25
25
  maxPaymentAttempts?: number;
26
- callbacks?: SetuPaymentCallbacks;
26
+ callbacks?: OttoRouterPaymentCallbacks;
27
27
  providerNpm?: string;
28
28
  promptCacheKey?: string;
29
29
  promptCacheRetention?: 'in_memory' | '24h';
@@ -32,33 +32,33 @@ export type SetuProviderOptions = {
32
32
  middleware?: LanguageModelV3Middleware | LanguageModelV3Middleware[];
33
33
  };
34
34
 
35
- export type SetuAuth = _SetuAuth;
35
+ export type OttoRouterAuth = _OttoRouterAuth;
36
36
 
37
- export type SetuBalanceResponse = BalanceResponse;
37
+ export type OttoRouterBalanceResponse = BalanceResponse;
38
38
 
39
39
  export type SolanaUsdcBalanceResponse = WalletUsdcBalance;
40
40
 
41
- export function createSetuFetch(
42
- auth: SetuAuth,
43
- options: SetuProviderOptions = {},
41
+ export function createOttoRouterFetch(
42
+ auth: OttoRouterAuth,
43
+ options: OttoRouterProviderOptions = {},
44
44
  ): typeof fetch {
45
- const setu = createSetu(buildSetuConfig(auth, options));
46
- return setu.fetch() as typeof fetch;
45
+ const ottorouter = createOttoRouter(buildOttoRouterConfig(auth, options));
46
+ return ottorouter.fetch() as typeof fetch;
47
47
  }
48
48
 
49
- export function createSetuModel(
49
+ export function createOttoRouterModel(
50
50
  model: string,
51
- auth: SetuAuth,
52
- options: SetuProviderOptions = {},
51
+ auth: OttoRouterAuth,
52
+ options: OttoRouterProviderOptions = {},
53
53
  ) {
54
- const setu = createSetu(buildSetuConfig(auth, options));
55
- return setu.model(model);
54
+ const ottorouter = createOttoRouter(buildOttoRouterConfig(auth, options));
55
+ return ottorouter.model(model);
56
56
  }
57
57
 
58
- function buildSetuConfig(
59
- auth: SetuAuth,
60
- options: SetuProviderOptions = {},
61
- ): SetuConfig {
58
+ function buildOttoRouterConfig(
59
+ auth: OttoRouterAuth,
60
+ options: OttoRouterProviderOptions = {},
61
+ ): OttoRouterConfig {
62
62
  return {
63
63
  auth,
64
64
  baseURL: options.baseURL,
@@ -78,10 +78,10 @@ function buildSetuConfig(
78
78
  };
79
79
  }
80
80
 
81
- export async function fetchSetuBalance(
82
- auth: SetuAuth,
81
+ export async function fetchOttoRouterBalance(
82
+ auth: OttoRouterAuth,
83
83
  baseURL?: string,
84
- ): Promise<SetuBalanceResponse | null> {
84
+ ): Promise<OttoRouterBalanceResponse | null> {
85
85
  return fetchBalance(auth, baseURL);
86
86
  }
87
87
 
@@ -90,7 +90,7 @@ export function getPublicKeyFromPrivate(privateKey: string): string | null {
90
90
  }
91
91
 
92
92
  export async function fetchSolanaUsdcBalance(
93
- auth: SetuAuth,
93
+ auth: OttoRouterAuth,
94
94
  network: 'mainnet' | 'devnet' = 'mainnet',
95
95
  ): Promise<SolanaUsdcBalanceResponse | null> {
96
96
  if (auth.privateKey) {
@@ -105,4 +105,4 @@ export async function fetchSolanaUsdcBalance(
105
105
  return null;
106
106
  }
107
107
 
108
- export { createSetu, type SetuInstance };
108
+ export { createOttoRouter, type OttoRouterInstance };
@@ -76,7 +76,7 @@ const pricingTable: Record<ProviderName, PricingEntry[]> = {
76
76
  opencode: [
77
77
  // Pricing from catalog entries; leave empty here
78
78
  ],
79
- setu: [
79
+ ottorouter: [
80
80
  // Pricing from catalog entries; leave empty here
81
81
  ],
82
82
  zai: [
@@ -34,7 +34,7 @@ const PREFERRED_FAST_MODELS: Partial<Record<ProviderId, string[]>> = {
34
34
  google: ['gemini-2.0-flash-lite'],
35
35
  openrouter: ['anthropic/claude-3.5-haiku'],
36
36
  opencode: ['claude-3-5-haiku'],
37
- setu: ['kimi-k2-turbo-preview'],
37
+ ottorouter: ['kimi-k2-turbo-preview'],
38
38
  zai: ['glm-4.5-flash'],
39
39
  copilot: ['gpt-4.1-mini'],
40
40
  };
@@ -8,7 +8,7 @@ export type ProviderId =
8
8
  | 'openrouter'
9
9
  | 'opencode'
10
10
  | 'copilot'
11
- | 'setu'
11
+ | 'ottorouter'
12
12
  | 'zai'
13
13
  | 'zai-coding'
14
14
  | 'moonshot'