upfynai-code 2.9.8 → 2.9.9

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/server/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  /**
3
3
  * Upfyn-Code CLI
4
4
  * by Thinqmesh Technologies
@@ -46,6 +46,12 @@ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
46
46
  const CONFIG_DIR = path.join(os.homedir(), '.upfynai');
47
47
  const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
48
48
 
49
+ /** Mask internal Railway URL for display */
50
+ function displayServerUrl(url) {
51
+ if (!url || url === 'https://upfynai-code-production.up.railway.app') return 'Upfyn Cloud';
52
+ try { return new URL(url).host; } catch { return url; }
53
+ }
54
+
49
55
  // Load environment variables from .env file if it exists
50
56
  function loadEnvFile() {
51
57
  try {
@@ -351,7 +357,7 @@ async function launchInteractive() {
351
357
  // 5. Show launch screen
352
358
  showLaunchScreen(packageJson.version, claudeBin, {
353
359
  relayStatus: config.relayKey && config.server
354
- ? `Auto-connecting to ${config.server}`
360
+ ? `Auto-connecting to ${displayServerUrl(config.server)}`
355
361
  : null,
356
362
  apiKey: config.anthropicApiKey || null,
357
363
  });
@@ -1,8 +1,8 @@
1
1
  let createClient;
2
2
  try {
3
3
  createClient = (await import('@libsql/client')).createClient;
4
- } catch {
5
- // @libsql/client not available — will use fallback or fail at runtime if DB is needed
4
+ } catch (e) {
5
+ console.warn('[DB] @libsql/client not available — cloud database features disabled.', e?.message || '');
6
6
  }
7
7
  import path from 'path';
8
8
  import fs from 'fs';
@@ -49,6 +49,9 @@ function resolveDbConfig() {
49
49
 
50
50
  function getDb() {
51
51
  if (!_db) {
52
+ if (!createClient) {
53
+ throw new Error('[DB] @libsql/client is not installed. Run: npm install @libsql/client');
54
+ }
52
55
  resolveDbConfig();
53
56
  _db = createClient({ url: _dbUrl, ...(_dbAuthToken ? { authToken: _dbAuthToken } : {}) });
54
57
  }
@@ -36,6 +36,13 @@ try {
36
36
 
37
37
  const CONFIG_DIR = path.join(os.homedir(), '.upfynai');
38
38
  const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
39
+ const CLOUD_SERVER = 'https://upfynai-code-production.up.railway.app';
40
+
41
+ /** Mask internal server URL for display */
42
+ function displayUrl(url) {
43
+ if (!url || url === CLOUD_SERVER) return 'Upfyn Cloud (cli.upfyn.com)';
44
+ try { return new URL(url).host; } catch { return url; }
45
+ }
39
46
 
40
47
  function loadConfig() {
41
48
  try {
@@ -163,7 +170,7 @@ function createRelayConnection(wsUrl, config = {}) {
163
170
  */
164
171
  export async function connectToServer(options = {}) {
165
172
  const config = loadConfig();
166
- const serverUrl = options.server || config.server || 'https://upfynai-code-production.up.railway.app';
173
+ const serverUrl = options.server || config.server || CLOUD_SERVER;
167
174
  const relayKey = options.key || config.relayKey;
168
175
 
169
176
  if (!relayKey) {
@@ -182,7 +189,7 @@ export async function connectToServer(options = {}) {
182
189
 
183
190
  saveConfig({ ...config, server: serverUrl, relayKey });
184
191
 
185
- await showConnectStartup(serverUrl, os.hostname(), os.userInfo().username, VERSION);
192
+ await showConnectStartup(displayUrl(serverUrl), os.hostname(), os.userInfo().username, VERSION);
186
193
 
187
194
  const wsUrl = serverUrl.replace(/^http/, 'ws') + '/relay?token=' + encodeURIComponent(relayKey);
188
195
 
@@ -210,7 +217,7 @@ export async function connectToServer(options = {}) {
210
217
  spinner.stop('Connected!');
211
218
  const nameMatch = data.message?.match(/Connected as (.+?)\./);
212
219
  const username = nameMatch ? nameMatch[1] : 'Unknown';
213
- showConnectionBanner(username, serverUrl);
220
+ showConnectionBanner(username, displayUrl(serverUrl));
214
221
 
215
222
  const agents = detectInstalledAgents();
216
223
  const installed = Object.entries(agents)
@@ -271,7 +278,7 @@ export async function connectToServer(options = {}) {
271
278
 
272
279
  ws.on('error', (err) => {
273
280
  if (err.code === 'ECONNREFUSED') {
274
- spinner.fail(`Cannot reach ${serverUrl}. Is the server running?`);
281
+ spinner.fail(`Cannot reach ${displayUrl(serverUrl)}. Is the server running?`);
275
282
  } else if (err.message?.includes('401')) {
276
283
  spinner.fail('Authentication failed (401). Your relay token may be invalid or expired.');
277
284
  logRelayEvent('!', 'Get a new token from the dashboard: https://cli.upfyn.com/dashboard', 'yellow');