@gokulvenkatareddy/cortex 0.1.10 → 0.1.12

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 (3) hide show
  1. package/bin/cortex +67 -24
  2. package/dist/cli.mjs +11 -19
  3. package/package.json +1 -1
package/bin/cortex CHANGED
@@ -1,37 +1,39 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * CORTEX — Global CLI entry point (CommonJS compatible)
3
+ * CORTEX — Global CLI entry point
4
4
  * Works anywhere: npm install -g @gokulvenkatareddy/cortex
5
- * Config lives in ~/.cortex/.env (the user's machine, NOT this package).
5
+ * Config lives in ~/.cortex/.env
6
6
  */
7
7
 
8
- const { execFileSync, spawn } = require('child_process');
9
- const fs = require('fs');
10
- const os = require('os');
11
- const path = require('path');
8
+ import { execFileSync, spawn } from 'child_process';
9
+ import fs from 'fs';
10
+ import os from 'os';
11
+ import path from 'path';
12
+ import { fileURLToPath } from 'url';
12
13
 
13
- const ROOT = path.resolve(__dirname, '..');
14
- const CLI_PATH = path.join(ROOT, 'dist', 'cli.mjs');
15
- const WIZARD = path.join(ROOT, 'scripts', 'setup-wizard.ts');
14
+ var __dirname = path.dirname(fileURLToPath(import.meta.url));
15
+ var ROOT = path.resolve(__dirname, '..');
16
+ var CLI_PATH = path.join(ROOT, 'dist', 'cli.mjs');
17
+ var WIZARD = path.join(ROOT, 'scripts', 'setup-wizard.ts');
16
18
 
17
- const CONFIG_DIR = path.join(os.homedir(), '.cortex');
18
- const CONFIG_ENV = path.join(CONFIG_DIR, '.env');
19
+ var CONFIG_DIR = path.join(os.homedir(), '.cortex');
20
+ var CONFIG_ENV = path.join(CONFIG_DIR, '.env');
19
21
 
20
- const args = process.argv.slice(2);
22
+ var args = process.argv.slice(2);
21
23
 
22
24
  function loadUserConfig() {
23
25
  if (!fs.existsSync(CONFIG_ENV)) return {};
24
- const lines = fs.readFileSync(CONFIG_ENV, 'utf8').split('\n');
25
- const env = {};
26
- for (const line of lines) {
27
- const m = line.match(/^([A-Z_]+[A-Z0-9_]*)=(.+)$/);
26
+ var lines = fs.readFileSync(CONFIG_ENV, 'utf8').split('\n');
27
+ var env = {};
28
+ for (var i = 0; i < lines.length; i++) {
29
+ var m = lines[i].match(/^([A-Za-z_][A-Za-z0-9_]*)=(.+)$/);
28
30
  if (m) env[m[1]] = m[2].trim();
29
31
  }
30
32
  return env;
31
33
  }
32
34
 
33
35
  function isConfigured() {
34
- const env = loadUserConfig();
36
+ var env = loadUserConfig();
35
37
  return !!(
36
38
  env['NVIDIA_API_KEY'] ||
37
39
  env['OPENAI_API_KEY'] ||
@@ -45,13 +47,13 @@ function isConfigured() {
45
47
  }
46
48
 
47
49
  function runWizard() {
48
- const runners = [
50
+ var runners = [
49
51
  ['bun', [WIZARD]],
50
52
  ['npx', ['--yes', 'tsx', WIZARD]],
51
53
  ];
52
- for (const [cmd, cmdArgs] of runners) {
54
+ for (var i = 0; i < runners.length; i++) {
53
55
  try {
54
- execFileSync(cmd, cmdArgs, { stdio: 'inherit', cwd: ROOT });
56
+ execFileSync(runners[i][0], runners[i][1], { stdio: 'inherit', cwd: ROOT });
55
57
  return;
56
58
  } catch (e) {
57
59
  continue;
@@ -66,9 +68,51 @@ function launchCortex(extraEnv) {
66
68
  console.error('\n❌ dist/cli.mjs not found.\n');
67
69
  process.exit(1);
68
70
  }
69
- const userConfig = loadUserConfig();
70
- const mergedEnv = Object.assign({}, process.env, userConfig, extraEnv || {});
71
- const proc = spawn('node', [CLI_PATH].concat(args), {
71
+
72
+ var userConfig = loadUserConfig();
73
+
74
+ // ─── Auto-detect provider and set the correct CORTEX_USE_* flag ──────────
75
+ // Without these flags, the CLI defaults to 'firstParty' (Anthropic login screen).
76
+ var provider = userConfig['CORTEX_PROVIDER'] || '';
77
+
78
+ if (!process.env.CORTEX_USE_OPENAI && !process.env.CORTEX_USE_GEMINI && !process.env.CORTEX_USE_GITHUB) {
79
+ if (provider === 'nvidia' || userConfig['NVIDIA_API_KEY']) {
80
+ userConfig['CORTEX_USE_OPENAI'] = '1';
81
+ userConfig['CORTEX_NVIDIA_ONLY'] = '1';
82
+ if (userConfig['NVIDIA_API_KEY'] && !userConfig['OPENAI_API_KEY']) {
83
+ userConfig['OPENAI_API_KEY'] = userConfig['NVIDIA_API_KEY'];
84
+ }
85
+ if (userConfig['NVIDIA_BASE_URL'] && !userConfig['OPENAI_BASE_URL']) {
86
+ userConfig['OPENAI_BASE_URL'] = userConfig['NVIDIA_BASE_URL'];
87
+ } else if (!userConfig['OPENAI_BASE_URL']) {
88
+ userConfig['OPENAI_BASE_URL'] = 'https://integrate.api.nvidia.com/v1';
89
+ }
90
+ } else if (provider === 'openai' || userConfig['OPENAI_API_KEY']) {
91
+ userConfig['CORTEX_USE_OPENAI'] = '1';
92
+ } else if (provider === 'gemini' || userConfig['GEMINI_API_KEY']) {
93
+ userConfig['CORTEX_USE_GEMINI'] = '1';
94
+ } else if (provider === 'groq' || userConfig['GROQ_API_KEY']) {
95
+ userConfig['CORTEX_USE_OPENAI'] = '1';
96
+ if (userConfig['GROQ_API_KEY'] && !userConfig['OPENAI_API_KEY']) {
97
+ userConfig['OPENAI_API_KEY'] = userConfig['GROQ_API_KEY'];
98
+ }
99
+ if (!userConfig['OPENAI_BASE_URL']) {
100
+ userConfig['OPENAI_BASE_URL'] = 'https://api.groq.com/openai/v1';
101
+ }
102
+ } else if (provider === 'openrouter') {
103
+ userConfig['CORTEX_USE_OPENAI'] = '1';
104
+ } else if (provider === 'ollama') {
105
+ userConfig['CORTEX_USE_OPENAI'] = '1';
106
+ if (!userConfig['OPENAI_API_KEY']) userConfig['OPENAI_API_KEY'] = 'ollama';
107
+ if (!userConfig['OPENAI_BASE_URL']) userConfig['OPENAI_BASE_URL'] = 'http://localhost:11434/v1';
108
+ } else if (userConfig['HF_TOKEN']) {
109
+ // HuggingFace is auto-detected by providers.ts via HF_TOKEN
110
+ }
111
+ }
112
+
113
+ var mergedEnv = Object.assign({}, process.env, userConfig, extraEnv || {});
114
+
115
+ var proc = spawn('node', [CLI_PATH].concat(args), {
72
116
  stdio: 'inherit',
73
117
  cwd: ROOT,
74
118
  env: mergedEnv,
@@ -76,7 +120,6 @@ function launchCortex(extraEnv) {
76
120
  proc.on('exit', function(code) { process.exit(code || 0); });
77
121
  }
78
122
 
79
- // ─── Entry point ───────────────────────────────────────────────────────────
80
123
  if (args[0] === 'setup' || args[0] === 'init' || args[0] === 'configure') {
81
124
  runWizard();
82
125
  launchCortex();
package/dist/cli.mjs CHANGED
@@ -103698,7 +103698,7 @@ function getAPIProvider() {
103698
103698
  return isEnvTruthy(process.env.CORTEX_USE_GEMINI) ? "gemini" : isEnvTruthy(process.env.CORTEX_USE_GITHUB) ? "github" : isEnvTruthy(process.env.CORTEX_USE_OPENAI) ? isCodexModel() ? "codex" : "openai" : isEnvTruthy(process.env.CORTEX_USE_BEDROCK) ? "bedrock" : isEnvTruthy(process.env.CORTEX_USE_VERTEX) ? "vertex" : isEnvTruthy(process.env.CORTEX_USE_FOUNDRY) ? "foundry" : process.env.HF_TOKEN ? "huggingface" : "firstParty";
103699
103699
  }
103700
103700
  function usesCORTEXAccountFlow() {
103701
- return getAPIProvider() === "firstParty";
103701
+ return false;
103702
103702
  }
103703
103703
  function isCodexModel() {
103704
103704
  const model = (process.env.OPENAI_MODEL || "").trim();
@@ -367814,7 +367814,7 @@ function getCORTEXEnvMetadata() {
367814
367814
  function getBuildAgeMinutes() {
367815
367815
  if (false)
367816
367816
  ;
367817
- const buildTime = new Date("2026-05-07T10:37:38.396Z").getTime();
367817
+ const buildTime = new Date("2026-05-07T10:53:02.411Z").getTime();
367818
367818
  if (isNaN(buildTime))
367819
367819
  return;
367820
367820
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -394605,7 +394605,7 @@ function buildPrimarySection() {
394605
394605
  }, undefined, false, undefined, this);
394606
394606
  return [{
394607
394607
  label: "Version",
394608
- value: "0.1.10"
394608
+ value: "0.1.12"
394609
394609
  }, {
394610
394610
  label: "Session name",
394611
394611
  value: nameValue
@@ -460184,7 +460184,7 @@ var init_bridge_kick = __esm(() => {
460184
460184
  var call60 = async () => {
460185
460185
  return {
460186
460186
  type: "text",
460187
- value: `${"99.0.0"} (built ${"2026-05-07T10:37:38.396Z"})`
460187
+ value: `${"99.0.0"} (built ${"2026-05-07T10:53:02.411Z"})`
460188
460188
  };
460189
460189
  }, version2, version_default;
460190
460190
  var init_version = __esm(() => {
@@ -534314,7 +534314,7 @@ function WelcomeV2() {
534314
534314
  dimColor: true,
534315
534315
  children: [
534316
534316
  "v",
534317
- "0.1.10",
534317
+ "0.1.12",
534318
534318
  " "
534319
534319
  ]
534320
534320
  }, undefined, true, undefined, this)
@@ -534514,7 +534514,7 @@ function WelcomeV2() {
534514
534514
  dimColor: true,
534515
534515
  children: [
534516
534516
  "v",
534517
- "0.1.10",
534517
+ "0.1.12",
534518
534518
  " "
534519
534519
  ]
534520
534520
  }, undefined, true, undefined, this)
@@ -534740,7 +534740,7 @@ function AppleTerminalWelcomeV2(t0) {
534740
534740
  dimColor: true,
534741
534741
  children: [
534742
534742
  "v",
534743
- "0.1.10",
534743
+ "0.1.12",
534744
534744
  " "
534745
534745
  ]
534746
534746
  }, undefined, true, undefined, this);
@@ -534994,7 +534994,7 @@ function AppleTerminalWelcomeV2(t0) {
534994
534994
  dimColor: true,
534995
534995
  children: [
534996
534996
  "v",
534997
- "0.1.10",
534997
+ "0.1.12",
534998
534998
  " "
534999
534999
  ]
535000
535000
  }, undefined, true, undefined, this);
@@ -554875,7 +554875,7 @@ Usage: cortex --remote "your task description"`, () => gracefulShutdown(1));
554875
554875
  pendingHookMessages
554876
554876
  }, renderAndRun);
554877
554877
  }
554878
- }).version("0.1.10 (CORTEX)", "-v, --version", "Output the version number");
554878
+ }).version("0.1.12 (CORTEX)", "-v, --version", "Output the version number");
554879
554879
  program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
554880
554880
  program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
554881
554881
  if (canUserConfigureAdvisor()) {
@@ -555433,13 +555433,6 @@ async function getProviderValidationError(env2 = process.env, options) {
555433
555433
  }
555434
555434
  return null;
555435
555435
  }
555436
- async function validateProviderEnvOrExit(env2 = process.env) {
555437
- const error = await getProviderValidationError(env2);
555438
- if (error) {
555439
- console.error(error);
555440
- process.exit(1);
555441
- }
555442
- }
555443
555436
 
555444
555437
  // src/entrypoints/cli.tsx
555445
555438
  try {
@@ -555470,7 +555463,7 @@ if (false) {}
555470
555463
  async function main2() {
555471
555464
  const args = process.argv.slice(2);
555472
555465
  if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
555473
- const v = typeof MACRO !== "undefined" ? "0.1.10" : "99.0.0-dev";
555466
+ const v = typeof MACRO !== "undefined" ? "0.1.12" : "99.0.0-dev";
555474
555467
  console.log(`${v} (CORTEX)`);
555475
555468
  return;
555476
555469
  }
@@ -555503,7 +555496,6 @@ async function main2() {
555503
555496
  applyProfileEnvToProcessEnv(process.env, startupEnv);
555504
555497
  }
555505
555498
  }
555506
- await validateProviderEnvOrExit();
555507
555499
  const { printStartupScreen: printStartupScreen2 } = await Promise.resolve().then(() => (init_StartupScreen(), exports_StartupScreen));
555508
555500
  await printStartupScreen2();
555509
555501
  if (process.env.CORTEX_NO_SHARE !== "1") {
@@ -555655,4 +555647,4 @@ ${DIM4} session id:${RESET4} ${BOLD2}${handle.sessionId}${RESET4} ${DIM4}(rotat
555655
555647
  }
555656
555648
  main2();
555657
555649
 
555658
- //# debugId=AAB29BFC16F3829C64756E2164756E21
555650
+ //# debugId=B294DE5C79990FEB64756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gokulvenkatareddy/cortex",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "CORTEX — Autonomous AGI Terminal. Any LLM, one command. NVIDIA, OpenAI, Gemini, Groq, Ollama and more.",
5
5
  "type": "module",
6
6
  "bin": {