juno-code 1.0.14 → 1.0.17

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/index.mjs CHANGED
@@ -44,7 +44,7 @@ var __export = (target, all) => {
44
44
  var version;
45
45
  var init_version = __esm({
46
46
  "src/version.ts"() {
47
- version = "1.0.14";
47
+ version = "1.0.17";
48
48
  }
49
49
  });
50
50
  function isHeadlessEnvironment() {
@@ -4424,6 +4424,7 @@ var CircularInheritanceError = class extends ProfileError {
4424
4424
  var ENV_VAR_MAPPING = {
4425
4425
  // Core settings
4426
4426
  JUNO_CODE_DEFAULT_SUBAGENT: "defaultSubagent",
4427
+ JUNO_CODE_DEFAULT_BACKEND: "defaultBackend",
4427
4428
  JUNO_CODE_DEFAULT_MAX_ITERATIONS: "defaultMaxIterations",
4428
4429
  JUNO_CODE_DEFAULT_MODEL: "defaultModel",
4429
4430
  // Logging settings
@@ -4446,6 +4447,7 @@ var ENV_VAR_MAPPING = {
4446
4447
  var LEGACY_ENV_VAR_MAPPING = {
4447
4448
  // Core settings
4448
4449
  JUNO_TASK_DEFAULT_SUBAGENT: "defaultSubagent",
4450
+ JUNO_TASK_DEFAULT_BACKEND: "defaultBackend",
4449
4451
  JUNO_TASK_DEFAULT_MAX_ITERATIONS: "defaultMaxIterations",
4450
4452
  JUNO_TASK_DEFAULT_MODEL: "defaultModel",
4451
4453
  // Logging settings
@@ -4466,6 +4468,7 @@ var LEGACY_ENV_VAR_MAPPING = {
4466
4468
  JUNO_TASK_SESSION_DIRECTORY: "sessionDirectory"
4467
4469
  };
4468
4470
  var SubagentTypeSchema = z.enum(["claude", "cursor", "codex", "gemini"]);
4471
+ var BackendTypeSchema = z.enum(["mcp", "shell"]);
4469
4472
  var LogLevelSchema = z.enum(["error", "warn", "info", "debug", "trace"]);
4470
4473
  var HookTypeSchema = z.enum(["START_RUN", "START_ITERATION", "END_ITERATION", "END_RUN"]);
4471
4474
  var HookSchema = z.object({
@@ -4475,6 +4478,7 @@ var HooksSchema = z.record(HookTypeSchema, HookSchema).optional();
4475
4478
  var JunoTaskConfigSchema = z.object({
4476
4479
  // Core settings
4477
4480
  defaultSubagent: SubagentTypeSchema.describe("Default subagent to use for task execution"),
4481
+ defaultBackend: BackendTypeSchema.describe("Default backend to use for task execution"),
4478
4482
  defaultMaxIterations: z.number().int().min(1).max(1e3).describe("Default maximum number of iterations for task execution"),
4479
4483
  defaultModel: z.string().optional().describe("Default model to use for the subagent"),
4480
4484
  // Logging settings
@@ -4499,6 +4503,7 @@ var JunoTaskConfigSchema = z.object({
4499
4503
  var DEFAULT_CONFIG = {
4500
4504
  // Core settings
4501
4505
  defaultSubagent: "claude",
4506
+ defaultBackend: "mcp",
4502
4507
  defaultMaxIterations: 50,
4503
4508
  // Logging settings
4504
4509
  logLevel: "info",
@@ -6330,7 +6335,7 @@ var AdvancedLogger = class {
6330
6335
  };
6331
6336
  this.addEntry(entry);
6332
6337
  const formatted = this.formatter.format(entry, this.options);
6333
- this.output(formatted);
6338
+ this.output(formatted, level);
6334
6339
  }
6335
6340
  /**
6336
6341
  * Start a timer for performance logging
@@ -6359,7 +6364,7 @@ var AdvancedLogger = class {
6359
6364
  };
6360
6365
  this.addEntry(entry);
6361
6366
  const formatted = this.formatter.format(entry, this.options);
6362
- this.output(formatted);
6367
+ this.output(formatted, level);
6363
6368
  }
6364
6369
  return duration;
6365
6370
  }
@@ -6378,7 +6383,7 @@ var AdvancedLogger = class {
6378
6383
  };
6379
6384
  this.addEntry(entry);
6380
6385
  const formatted = this.formatter.format(entry, this.options);
6381
- this.output(formatted);
6386
+ this.output(formatted, level);
6382
6387
  }
6383
6388
  /**
6384
6389
  * Log with specific session ID
@@ -6395,7 +6400,7 @@ var AdvancedLogger = class {
6395
6400
  };
6396
6401
  this.addEntry(entry);
6397
6402
  const formatted = this.formatter.format(entry, this.options);
6398
- this.output(formatted);
6403
+ this.output(formatted, level);
6399
6404
  }
6400
6405
  /**
6401
6406
  * Create a child logger with specific context
@@ -6463,9 +6468,13 @@ var AdvancedLogger = class {
6463
6468
  /**
6464
6469
  * Output formatted log
6465
6470
  */
6466
- output(formatted) {
6471
+ output(formatted, level) {
6467
6472
  if (this.options.output === "console" || this.options.output === "both") {
6468
- console.log(formatted);
6473
+ if (level >= 3 /* WARN */) {
6474
+ console.error(formatted);
6475
+ } else {
6476
+ console.log(formatted);
6477
+ }
6469
6478
  }
6470
6479
  if (this.options.output === "file" || this.options.output === "both") {
6471
6480
  this.writeToFile(formatted);
@@ -6969,9 +6978,6 @@ var ExecutionEngine = class extends EventEmitter {
6969
6978
  * Setup error handling for the engine
6970
6979
  */
6971
6980
  setupErrorHandling() {
6972
- this.engineConfig.mcpClient.on("connection:error", (error) => {
6973
- this.emit("engine:error", error);
6974
- });
6975
6981
  process.on("uncaughtException", (error) => {
6976
6982
  this.emit("engine:uncaught-exception", error);
6977
6983
  });
@@ -6983,7 +6989,22 @@ var ExecutionEngine = class extends EventEmitter {
6983
6989
  * Setup progress tracking for the engine
6984
6990
  */
6985
6991
  setupProgressTracking() {
6986
- this.engineConfig.mcpClient.onProgress(async (event) => {
6992
+ }
6993
+ /**
6994
+ * Initialize backend for execution request
6995
+ */
6996
+ async initializeBackend(request) {
6997
+ const backend = await this.engineConfig.backendManager.selectBackend({
6998
+ type: request.backend,
6999
+ config: this.engineConfig.config,
7000
+ workingDirectory: request.workingDirectory,
7001
+ mcpServerName: request.mcpServerName || this.engineConfig.config.mcpServerName,
7002
+ additionalOptions: {
7003
+ sessionId: request.requestId,
7004
+ timeout: request.timeoutMs || this.engineConfig.config.mcpTimeout
7005
+ }
7006
+ });
7007
+ backend.onProgress(async (event) => {
6987
7008
  try {
6988
7009
  for (const processor of this.engineConfig.progressConfig.processors) {
6989
7010
  await processor.process(event);
@@ -6996,6 +7017,7 @@ var ExecutionEngine = class extends EventEmitter {
6996
7017
  this.emit("progress:error", { event, error });
6997
7018
  }
6998
7019
  });
7020
+ engineLogger.info(`Initialized ${backend.name} backend for execution`);
6999
7021
  }
7000
7022
  /**
7001
7023
  * Validate execution request parameters
@@ -7096,6 +7118,7 @@ var ExecutionEngine = class extends EventEmitter {
7096
7118
  async executeInternal(context) {
7097
7119
  context.status = "running" /* RUNNING */;
7098
7120
  context.sessionContext = { ...context.sessionContext, state: "active" };
7121
+ await this.initializeBackend(context.request);
7099
7122
  try {
7100
7123
  if (this.engineConfig.config.hooks) {
7101
7124
  await executeHook("START_RUN", this.engineConfig.config.hooks, {
@@ -7106,6 +7129,7 @@ var ExecutionEngine = class extends EventEmitter {
7106
7129
  sessionId: context.sessionContext.sessionId,
7107
7130
  requestId: context.request.requestId,
7108
7131
  subagent: context.request.subagent,
7132
+ backend: context.request.backend,
7109
7133
  maxIterations: context.request.maxIterations,
7110
7134
  instruction: context.request.instruction
7111
7135
  }
@@ -7219,7 +7243,7 @@ var ExecutionEngine = class extends EventEmitter {
7219
7243
  }
7220
7244
  };
7221
7245
  try {
7222
- const toolResult = await this.engineConfig.mcpClient.callTool(toolRequest);
7246
+ const toolResult = await this.engineConfig.backendManager.execute(toolRequest);
7223
7247
  const iterationEnd = /* @__PURE__ */ new Date();
7224
7248
  const duration = iterationEnd.getTime() - iterationStart.getTime();
7225
7249
  const iterationResult = {
@@ -7616,10 +7640,10 @@ var ExecutionEngine = class extends EventEmitter {
7616
7640
  return new Promise((resolve5) => setTimeout(resolve5, ms));
7617
7641
  }
7618
7642
  };
7619
- function createExecutionEngine(config, mcpClient) {
7643
+ function createExecutionEngine(config, backendManager) {
7620
7644
  return new ExecutionEngine({
7621
7645
  config,
7622
- mcpClient,
7646
+ backendManager,
7623
7647
  errorRecovery: DEFAULT_ERROR_RECOVERY_CONFIG,
7624
7648
  rateLimitConfig: DEFAULT_RATE_LIMIT_CONFIG,
7625
7649
  progressConfig: DEFAULT_PROGRESS_CONFIG
@@ -7630,12 +7654,16 @@ function createExecutionRequest(options) {
7630
7654
  requestId: options.requestId || `req-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
7631
7655
  instruction: options.instruction,
7632
7656
  subagent: options.subagent || "claude",
7657
+ backend: options.backend || "mcp",
7633
7658
  workingDirectory: options.workingDirectory || process.cwd(),
7634
7659
  maxIterations: options.maxIterations || 50
7635
7660
  };
7636
7661
  if (options.model !== void 0) {
7637
7662
  result.model = options.model;
7638
7663
  }
7664
+ if (options.mcpServerName !== void 0) {
7665
+ result.mcpServerName = options.mcpServerName;
7666
+ }
7639
7667
  return result;
7640
7668
  }
7641
7669
 
@@ -10949,7 +10977,8 @@ var MCPConfigLoader = class {
10949
10977
  });
10950
10978
  if (serverConfig.env) {
10951
10979
  for (const [envKey, envValue] of Object.entries(serverConfig.env)) {
10952
- if (envValue.includes("/") && !path5.isAbsolute(envValue)) {
10980
+ const isUrl = /^[a-z][a-z0-9+.-]*:\/\//i.test(envValue);
10981
+ if (!isUrl && envValue.includes("/") && !path5.isAbsolute(envValue)) {
10953
10982
  serverConfig.env[envKey] = path5.resolve(configDir, "..", envValue);
10954
10983
  }
10955
10984
  }
@@ -11065,7 +11094,7 @@ var JunoLogger = class {
11065
11094
  const formattedMessage = this.formatMessage(levelName, message);
11066
11095
  await this.writeToLog(formattedMessage);
11067
11096
  if (this.enableConsoleLogging && writeToConsole) {
11068
- console.log(formattedMessage.trim());
11097
+ console.error(formattedMessage.trim());
11069
11098
  }
11070
11099
  }
11071
11100
  /**