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.mjs CHANGED
@@ -6461,6 +6461,8 @@ var init_shell_backend = __esm({
6461
6461
  eventCounter = 0;
6462
6462
  jsonBuffer = "";
6463
6463
  // Buffer for handling partial JSON objects
6464
+ logFilePath = null;
6465
+ // Path to current log file
6464
6466
  /**
6465
6467
  * Configure the shell backend
6466
6468
  */
@@ -6492,6 +6494,15 @@ var init_shell_backend = __esm({
6492
6494
  }
6493
6495
  const startTime = Date.now();
6494
6496
  const toolId = `shell_${request.toolName}_${startTime}`;
6497
+ const subagentType = this.extractSubagentFromToolName(request.toolName);
6498
+ try {
6499
+ this.logFilePath = await this.createLogFile(subagentType);
6500
+ } catch (error) {
6501
+ if (this.config.debug) {
6502
+ engineLogger.warn(`Failed to create log file, continuing without file logging: ${error instanceof Error ? error.message : String(error)}`);
6503
+ }
6504
+ this.logFilePath = null;
6505
+ }
6495
6506
  await this.emitProgressEvent({
6496
6507
  sessionId: request.metadata?.sessionId || "unknown",
6497
6508
  timestamp: /* @__PURE__ */ new Date(),
@@ -6507,7 +6518,6 @@ var init_shell_backend = __esm({
6507
6518
  }
6508
6519
  });
6509
6520
  try {
6510
- const subagentType = this.extractSubagentFromToolName(request.toolName);
6511
6521
  const scriptPath = await this.findScriptForSubagent(subagentType);
6512
6522
  const result = await this.executeScript(scriptPath, request, toolId);
6513
6523
  const duration = Date.now() - startTime;
@@ -6597,6 +6607,46 @@ var init_shell_backend = __esm({
6597
6607
  // =============================================================================
6598
6608
  // Private Implementation Methods
6599
6609
  // =============================================================================
6610
+ /**
6611
+ * Create log file path and ensure log directory exists
6612
+ */
6613
+ async createLogFile(subagentName) {
6614
+ const now = /* @__PURE__ */ new Date();
6615
+ 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");
6616
+ const logDir = path3.join(this.config.workingDirectory, ".juno_task", "logs");
6617
+ try {
6618
+ await fs3.ensureDir(logDir);
6619
+ } catch (error) {
6620
+ if (this.config?.debug) {
6621
+ engineLogger.warn(`Failed to create log directory: ${error instanceof Error ? error.message : String(error)}`);
6622
+ }
6623
+ throw new Error(`Failed to create log directory: ${logDir}`);
6624
+ }
6625
+ const logFileName = `${subagentName}_shell_${timestamp}.log`;
6626
+ const logFilePath = path3.join(logDir, logFileName);
6627
+ if (this.config?.debug) {
6628
+ engineLogger.debug(`Created log file path: ${logFilePath}`);
6629
+ }
6630
+ return logFilePath;
6631
+ }
6632
+ /**
6633
+ * Write log entry to file
6634
+ */
6635
+ async writeToLogFile(message) {
6636
+ if (!this.logFilePath) {
6637
+ return;
6638
+ }
6639
+ try {
6640
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
6641
+ const logEntry = `[${timestamp}] ${message}
6642
+ `;
6643
+ await fs3.appendFile(this.logFilePath, logEntry, "utf-8");
6644
+ } catch (error) {
6645
+ if (this.config?.debug) {
6646
+ engineLogger.warn(`Failed to write to log file: ${error instanceof Error ? error.message : String(error)}`);
6647
+ }
6648
+ }
6649
+ }
6600
6650
  /**
6601
6651
  * Extract subagent type from tool name
6602
6652
  */
@@ -7007,6 +7057,10 @@ var init_shell_backend = __esm({
7007
7057
  * Emit progress event to all callbacks
7008
7058
  */
7009
7059
  async emitProgressEvent(event) {
7060
+ if (this.logFilePath) {
7061
+ const logMessage = `[${event.type}] ${event.content}${event.metadata ? " | metadata: " + JSON.stringify(event.metadata) : ""}`;
7062
+ await this.writeToLogFile(logMessage);
7063
+ }
7010
7064
  for (const callback of this.progressCallbacks) {
7011
7065
  try {
7012
7066
  await callback(event);
@@ -12792,8 +12846,10 @@ var init_main = __esm({
12792
12846
  }
12793
12847
  onProgress(event) {
12794
12848
  const timestamp = event.timestamp.toLocaleTimeString();
12795
- if (event.metadata?.rawJsonOutput) {
12849
+ if (event.metadata?.rawJsonOutput || event.metadata?.format === "text" && event.metadata?.raw === true) {
12796
12850
  this.hasStreamedJsonOutput = true;
12851
+ }
12852
+ if (event.metadata?.rawJsonOutput) {
12797
12853
  try {
12798
12854
  const jsonObj = JSON.parse(event.content);
12799
12855
  const formattedJson = this.colorizeJson(jsonObj);
@@ -17872,6 +17928,19 @@ var ProgressDisplay = class {
17872
17928
  return;
17873
17929
  }
17874
17930
  }
17931
+ if (event.metadata?.format === "text") {
17932
+ try {
17933
+ const jsonObj = JSON.parse(event.content);
17934
+ const formattedJson = this.colorizeJson(jsonObj);
17935
+ writeTerminalProgress(`${chalk12.gray(timestamp)} ${chalk12.cyan(backend)} ${formattedJson}
17936
+ `);
17937
+ return;
17938
+ } catch (error) {
17939
+ writeTerminalProgress(chalk12.gray(`[${timestamp}] ${backend} ${event.type}: ${event.content}
17940
+ `));
17941
+ return;
17942
+ }
17943
+ }
17875
17944
  const toolName = event.metadata?.toolName || "unknown";
17876
17945
  const phase = event.metadata?.phase || "";
17877
17946
  const duration = event.metadata?.duration;