@appchy/jarvis 0.1.13 → 0.1.14

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/dist/bin.js CHANGED
@@ -9,7 +9,7 @@ import os4 from "os";
9
9
  import fs from "fs";
10
10
  import path from "path";
11
11
  import os from "os";
12
- var CONFIG_DIR = path.join(os.homedir(), ".jarvis");
12
+ var CONFIG_DIR = process.env.JARVIS_CONFIG_DIR ?? path.join(os.homedir(), ".jarvis");
13
13
  var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
14
14
  function loadConfig() {
15
15
  try {
@@ -2627,6 +2627,7 @@ function createUpstreamClient(config) {
2627
2627
  }
2628
2628
  });
2629
2629
  ws.on("close", (code) => {
2630
+ console.error("[Upstream] Connection closed, code:", code);
2630
2631
  if (closed) return;
2631
2632
  if (code === 4001 || code === 4003) {
2632
2633
  if (config.refreshToken) {
@@ -2678,6 +2679,7 @@ function createUpstreamClient(config) {
2678
2679
  reconnectTimer = setTimeout(connect, 3e3);
2679
2680
  });
2680
2681
  ws.on("error", (err) => {
2682
+ console.error("[Upstream] Connection error:", err.message);
2681
2683
  logger.sys.error("[Upstream] Connection error", {
2682
2684
  error: err.message
2683
2685
  });
@@ -4925,13 +4927,6 @@ async function ensureSetup() {
4925
4927
  }
4926
4928
  function createCli() {
4927
4929
  const program = new Command().name("jarvis").description("Jarvis local agent \u2014 runs Claude Code on your machine").version(PKG_VERSION);
4928
- program.argument("[message]", "Optional initial message to send").option("--model <id>", "Model (e.g., claude-opus-4-20250514)").option("--mode <mode>", "Permission mode: supervised|auto|plan|yolo").option("--thinking <config>", "Thinking: adaptive|enabled|disabled").option("--thinking-budget <n>", "Token budget when thinking=enabled").option("--max-turns <n>", "Max turns per task").option("-p, --port <port>", "Agent server port", "7862").option("-w, --workspace <path>", "Workspace root path").option("--no-server", "Connect to existing server, don't auto-start").action(async (message, opts) => {
4929
- if (message && program.commands.some((c) => c.name() === message)) {
4930
- return;
4931
- }
4932
- await ensureSetup();
4933
- await launchChat(opts);
4934
- });
4935
4930
  program.command("connect <token>").description("Connect to Jarvis cloud using a token from the web UI").option("-w, --workspace <path>", "Workspace root path for repo operations").action((token, opts) => {
4936
4931
  try {
4937
4932
  const parsed = parseConnectToken(token);
@@ -4959,14 +4954,18 @@ function createCli() {
4959
4954
  }
4960
4955
  });
4961
4956
  program.command("start").description("Start the local agent (runs as background daemon)").option("-p, --port <port>", "Local WS server port", "7862").option("-w, --workspace <path>", "Workspace root path").option("--api-key <key>", "Anthropic API key (for local-only use)").option("--no-upstream", "Don't connect to cloud (local-only mode)").option("--foreground", "Run in foreground (don't daemonize)").action(async (opts) => {
4962
- await ensureSetup();
4957
+ if (!opts.foreground) {
4958
+ await ensureSetup();
4959
+ }
4963
4960
  const config = loadConfig();
4964
4961
  const port = parseInt(opts.port, 10);
4965
- const alreadyRunning = await isPortInUse(port);
4966
- if (alreadyRunning) {
4967
- console.log(`Jarvis agent is already running on ws://127.0.0.1:${port}`);
4968
- console.log(`Use 'jarvis restart' to restart, or 'jarvis logs' to view logs.`);
4969
- return;
4962
+ if (!opts.foreground) {
4963
+ const alreadyRunning = await isPortInUse(port);
4964
+ if (alreadyRunning) {
4965
+ console.log(`Jarvis agent is already running on ws://127.0.0.1:${port}`);
4966
+ console.log(`Use 'jarvis restart' to restart, or 'jarvis logs' to view logs.`);
4967
+ return;
4968
+ }
4970
4969
  }
4971
4970
  const workspacePath = opts.workspace ?? config?.workspacePath ?? process.cwd();
4972
4971
  const userId = config?.userId ?? process.env.JARVIS_USER_ID ?? "local";
@@ -4974,6 +4973,9 @@ function createCli() {
4974
4973
  const useSubscription = !explicitApiKey;
4975
4974
  const anthropicApiKey = explicitApiKey;
4976
4975
  if (opts.foreground) {
4976
+ if (useSubscription && process.env.ANTHROPIC_API_KEY) {
4977
+ delete process.env.ANTHROPIC_API_KEY;
4978
+ }
4977
4979
  await startAgent({
4978
4980
  port,
4979
4981
  workspacePath,
@@ -5018,7 +5020,12 @@ function createCli() {
5018
5020
  detached: true,
5019
5021
  stdio: ["ignore", logFd, logFd],
5020
5022
  cwd: workspacePath,
5021
- env: { ...process.env, NODE_NO_WARNINGS: "1" }
5023
+ env: {
5024
+ ...process.env,
5025
+ NODE_NO_WARNINGS: "1",
5026
+ // Strip API key when using subscription to prevent SDK from picking it up
5027
+ ...useSubscription ? { ANTHROPIC_API_KEY: "" } : {}
5028
+ }
5022
5029
  }
5023
5030
  );
5024
5031
  child.unref();
@@ -5129,6 +5136,10 @@ function createCli() {
5129
5136
  clearConfig();
5130
5137
  console.log("Configuration cleared.");
5131
5138
  });
5139
+ program.command("chat", { isDefault: true, hidden: true }).description("Interactive TUI").option("--model <id>", "Model (e.g., claude-opus-4-20250514)").option("--mode <mode>", "Permission mode: supervised|auto|plan|yolo").option("--thinking <config>", "Thinking: adaptive|enabled|disabled").option("--thinking-budget <n>", "Token budget when thinking=enabled").option("--max-turns <n>", "Max turns per task").option("-p, --port <port>", "Agent server port", "7862").option("-w, --workspace <path>", "Workspace root path").option("--no-server", "Connect to existing server, don't auto-start").action(async (opts) => {
5140
+ await ensureSetup();
5141
+ await launchChat(opts);
5142
+ });
5132
5143
  return program;
5133
5144
  }
5134
5145