sam-coder-cli 1.0.2 → 1.0.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.
Files changed (2) hide show
  1. package/bin/agi-cli.js +8 -3
  2. package/package.json +1 -1
package/bin/agi-cli.js CHANGED
@@ -3,13 +3,14 @@
3
3
  const ui = require('./ui.js');
4
4
  const readline = require('readline');
5
5
  const path = require('path');
6
+ const os = require('os');
6
7
  const fs = require('fs').promises;
7
8
  const { exec } = require('child_process');
8
9
  const util = require('util');
9
10
  const execAsync = util.promisify(exec);
10
11
 
11
12
  // Configuration
12
- const CONFIG_PATH = path.join(__dirname, 'config.json');
13
+ const CONFIG_PATH = path.join(os.homedir(), '.sam-coder-config.json');
13
14
  let OPENROUTER_API_KEY;
14
15
  const MODEL = 'deepseek/deepseek-chat-v3-0324:free';
15
16
  const API_BASE_URL = 'https://openrouter.ai/api/v1';
@@ -399,6 +400,9 @@ async function callOpenRouterWithTools(messages) {
399
400
  });
400
401
 
401
402
  if (!response.ok) {
403
+ if (response.status === 401) {
404
+ throw new Error('AuthenticationError: Invalid API key. Please run /setup to reconfigure.');
405
+ }
402
406
  const error = await response.json();
403
407
  throw new Error(`API error: ${error.error?.message || response.statusText}`);
404
408
  }
@@ -430,6 +434,9 @@ async function callOpenRouterWithFunctions(messages) {
430
434
  });
431
435
 
432
436
  if (!response.ok) {
437
+ if (response.status === 401) {
438
+ throw new Error('AuthenticationError: Invalid API key. Please run /setup to reconfigure.');
439
+ }
433
440
  const error = await response.json();
434
441
  throw new Error(`API error: ${error.error?.message || response.statusText}`);
435
442
  }
@@ -789,8 +796,6 @@ async function start() {
789
796
  let config = await readConfig();
790
797
  if (!config || !config.OPENROUTER_API_KEY) {
791
798
  config = await runSetup();
792
- console.log('\nSetup complete. Please start the application again.');
793
- process.exit(0);
794
799
  }
795
800
 
796
801
  OPENROUTER_API_KEY = config.OPENROUTER_API_KEY;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sam-coder-cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "SAM-CODER: An animated command-line AI assistant with agency capabilities.",
5
5
  "main": "bin/agi-cli.js",
6
6
  "bin": {