langtrain 0.2.3 → 0.2.5

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": "langtrain",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Unified JavaScript SDK for Langtrain Ecosystem",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/src/cli/auth.ts CHANGED
@@ -6,7 +6,12 @@ import { exec } from 'child_process';
6
6
  import { promisify } from 'util';
7
7
 
8
8
  const execAsync = promisify(exec);
9
- const API_BASE = 'https://api.langtrain.ai/api/v1';
9
+
10
+ function getApiBase() {
11
+ const config = getConfig();
12
+ const base = (config.baseUrl || 'https://api.langtrain.xyz').replace(/\/$/, '');
13
+ return `${base}/api/v1`;
14
+ }
10
15
 
11
16
  async function openBrowser(url: string) {
12
17
  try {
@@ -55,7 +60,7 @@ export async function handleLogin() {
55
60
 
56
61
  try {
57
62
  // 1. Request device code
58
- const { data: codeData } = await axios.post(`${API_BASE}/auth/device/code`);
63
+ const { data: codeData } = await axios.post(`${getApiBase()}/auth/device/code`);
59
64
  const { device_code, user_code, verification_url, expires_in, interval } = codeData;
60
65
 
61
66
  s.stop(green('Connected.'));
@@ -80,7 +85,7 @@ export async function handleLogin() {
80
85
 
81
86
  while (Date.now() - startTime < timeout) {
82
87
  try {
83
- const { data: tokenData } = await axios.post(`${API_BASE}/auth/device/token?device_code=${device_code}`);
88
+ const { data: tokenData } = await axios.post(`${getApiBase()}/auth/device/token?device_code=${device_code}`);
84
89
 
85
90
  if (tokenData.status === 'approved') {
86
91
  const apiKey = tokenData.api_key;