juno-code 1.0.22 → 1.0.24

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/cli.js CHANGED
@@ -6496,6 +6496,8 @@ var init_shell_backend = __esm({
6496
6496
  eventCounter = 0;
6497
6497
  jsonBuffer = "";
6498
6498
  // Buffer for handling partial JSON objects
6499
+ logFilePath = null;
6500
+ // Path to current log file
6499
6501
  /**
6500
6502
  * Configure the shell backend
6501
6503
  */
@@ -6527,6 +6529,15 @@ var init_shell_backend = __esm({
6527
6529
  }
6528
6530
  const startTime = Date.now();
6529
6531
  const toolId = `shell_${request.toolName}_${startTime}`;
6532
+ const subagentType = this.extractSubagentFromToolName(request.toolName);
6533
+ try {
6534
+ this.logFilePath = await this.createLogFile(subagentType);
6535
+ } catch (error) {
6536
+ if (this.config.debug) {
6537
+ engineLogger.warn(`Failed to create log file, continuing without file logging: ${error instanceof Error ? error.message : String(error)}`);
6538
+ }
6539
+ this.logFilePath = null;
6540
+ }
6530
6541
  await this.emitProgressEvent({
6531
6542
  sessionId: request.metadata?.sessionId || "unknown",
6532
6543
  timestamp: /* @__PURE__ */ new Date(),
@@ -6542,7 +6553,6 @@ var init_shell_backend = __esm({
6542
6553
  }
6543
6554
  });
6544
6555
  try {
6545
- const subagentType = this.extractSubagentFromToolName(request.toolName);
6546
6556
  const scriptPath = await this.findScriptForSubagent(subagentType);
6547
6557
  const result = await this.executeScript(scriptPath, request, toolId);
6548
6558
  const duration = Date.now() - startTime;
@@ -6632,6 +6642,46 @@ var init_shell_backend = __esm({
6632
6642
  // =============================================================================
6633
6643
  // Private Implementation Methods
6634
6644
  // =============================================================================
6645
+ /**
6646
+ * Create log file path and ensure log directory exists
6647
+ */
6648
+ async createLogFile(subagentName) {
6649
+ const now = /* @__PURE__ */ new Date();
6650
+ const timestamp = now.getFullYear().toString() + (now.getMonth() + 1).toString().padStart(2, "0") + now.getDate().toString().padStart(2, "0") + "_" + now.getHours().toString().padStart(2, "0") + now.getMinutes().toString().padStart(2, "0") + now.getSeconds().toString().padStart(2, "0");
6651
+ const logDir = path3__namespace.join(this.config.workingDirectory, ".juno_task", "logs");
6652
+ try {
6653
+ await fs3__default.default.ensureDir(logDir);
6654
+ } catch (error) {
6655
+ if (this.config?.debug) {
6656
+ engineLogger.warn(`Failed to create log directory: ${error instanceof Error ? error.message : String(error)}`);
6657
+ }
6658
+ throw new Error(`Failed to create log directory: ${logDir}`);
6659
+ }
6660
+ const logFileName = `${subagentName}_shell_${timestamp}.log`;
6661
+ const logFilePath = path3__namespace.join(logDir, logFileName);
6662
+ if (this.config?.debug) {
6663
+ engineLogger.debug(`Created log file path: ${logFilePath}`);
6664
+ }
6665
+ return logFilePath;
6666
+ }
6667
+ /**
6668
+ * Write log entry to file
6669
+ */
6670
+ async writeToLogFile(message) {
6671
+ if (!this.logFilePath) {
6672
+ return;
6673
+ }
6674
+ try {
6675
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
6676
+ const logEntry = `[${timestamp}] ${message}
6677
+ `;
6678
+ await fs3__default.default.appendFile(this.logFilePath, logEntry, "utf-8");
6679
+ } catch (error) {
6680
+ if (this.config?.debug) {
6681
+ engineLogger.warn(`Failed to write to log file: ${error instanceof Error ? error.message : String(error)}`);
6682
+ }
6683
+ }
6684
+ }
6635
6685
  /**
6636
6686
  * Extract subagent type from tool name
6637
6687
  */
@@ -7042,6 +7092,10 @@ var init_shell_backend = __esm({
7042
7092
  * Emit progress event to all callbacks
7043
7093
  */
7044
7094
  async emitProgressEvent(event) {
7095
+ if (this.logFilePath) {
7096
+ const logMessage = `[${event.type}] ${event.content}${event.metadata ? " | metadata: " + JSON.stringify(event.metadata) : ""}`;
7097
+ await this.writeToLogFile(logMessage);
7098
+ }
7045
7099
  for (const callback of this.progressCallbacks) {
7046
7100
  try {
7047
7101
  await callback(event);
@@ -12827,8 +12881,10 @@ var init_main = __esm({
12827
12881
  }
12828
12882
  onProgress(event) {
12829
12883
  const timestamp = event.timestamp.toLocaleTimeString();
12830
- if (event.metadata?.rawJsonOutput) {
12884
+ if (event.metadata?.rawJsonOutput || event.metadata?.format === "text" && event.metadata?.raw === true) {
12831
12885
  this.hasStreamedJsonOutput = true;
12886
+ }
12887
+ if (event.metadata?.rawJsonOutput) {
12832
12888
  try {
12833
12889
  const jsonObj = JSON.parse(event.content);
12834
12890
  const formattedJson = this.colorizeJson(jsonObj);
@@ -17907,6 +17963,19 @@ var ProgressDisplay = class {
17907
17963
  return;
17908
17964
  }
17909
17965
  }
17966
+ if (event.metadata?.format === "text") {
17967
+ try {
17968
+ const jsonObj = JSON.parse(event.content);
17969
+ const formattedJson = this.colorizeJson(jsonObj);
17970
+ writeTerminalProgress(`${chalk12__default.default.gray(timestamp)} ${chalk12__default.default.cyan(backend)} ${formattedJson}
17971
+ `);
17972
+ return;
17973
+ } catch (error) {
17974
+ writeTerminalProgress(chalk12__default.default.gray(`[${timestamp}] ${backend} ${event.type}: ${event.content}
17975
+ `));
17976
+ return;
17977
+ }
17978
+ }
17910
17979
  const toolName = event.metadata?.toolName || "unknown";
17911
17980
  const phase = event.metadata?.phase || "";
17912
17981
  const duration = event.metadata?.duration;