import { fileURLToPath as __fileURLToPath } from 'url';
import { dirname as __pathDirname } from 'path';
const __filename = __fileURLToPath(import.meta.url);
const __dirname = __pathDirname(__filename);
import { logger } from "../monitoring/logger.js";
class AutoContext {
  frameManager;
  constructor(frameManager) {
    this.frameManager = frameManager;
  }
  /**
   * Initialize a session context
   */
  initializeSession(command) {
    try {
      const sessionFrame = this.frameManager.createFrame({
        type: "task",
        name: "Session",
        inputs: {
          command,
          timestamp: (/* @__PURE__ */ new Date()).toISOString(),
          cwd: process.cwd()
        }
      });
      logger.info("Session context initialized", {
        frameId: sessionFrame,
        depth: this.frameManager.getStackDepth()
      });
    } catch (error) {
      logger.error("Failed to initialize session context", error);
    }
  }
  /**
   * Create a command context
   */
  createCommandContext(command, args) {
    try {
      const frameId = this.frameManager.createFrame({
        type: "tool_scope",
        name: command,
        inputs: args
      });
      logger.info("Command context created", {
        frameId,
        command,
        depth: this.frameManager.getStackDepth()
      });
      return frameId;
    } catch (error) {
      logger.error("Failed to create command context", error);
      return null;
    }
  }
  /**
   * Auto-save important context
   */
  autoSaveContext(data, importance = 5) {
    try {
      const currentFrame = this.frameManager.getCurrentFrameId();
      if (currentFrame) {
        this.frameManager.addEvent(
          "observation",
          {
            type: "context_save",
            data,
            importance,
            timestamp: (/* @__PURE__ */ new Date()).toISOString()
          },
          currentFrame
        );
      }
    } catch (error) {
      logger.error("Failed to auto-save context", error);
    }
  }
}
export {
  AutoContext
};
//# sourceMappingURL=auto-context.js.map
