// src/interfaces/chat-session.ts
// Copyright (C) 2026 Rob Colbert <rob.colbert@openplatform.us>
// Licensed under the Apache License, Version 2.0

import type { IUser } from "./user.js";
import type { IProject } from "./project.js";

import { GadgetId } from "../lib/gadget-id.ts";
import { IAiProvider } from "./ai-provider.ts";
import { HydratedDocument } from "mongoose";

export enum ChatSessionMode {
  Plan = "plan", // for planning and brainstorming
  Build = "build", // for building and coding
  Test = "test", // for testing and debugging
  Ship = "ship", // for finalizing and shipping
  Develop = "dev", // for working on the Gadget Code harness itself
}

export interface IChatSessionPin {
  _id: string;
  content: string;
}

export type ReasoningEffort = "off" | "low" | "medium" | "high";

export interface IChatSession {
  _id: GadgetId;
  createdAt: Date;
  lastMessageAt?: Date;
  user: IUser | GadgetId;
  project: IProject | GadgetId;
  name: string;
  mode: ChatSessionMode;
  provider: IAiProvider | GadgetId;
  selectedModel: string;
  reasoningEffort?: ReasoningEffort;
  numCtx?: number;
  stats: {
    turnCount: number;
    toolCallCount: number;
    inputTokens: number;
    outputTokens: number;
  };
  pins: IChatSessionPin[];
}

export type ChatSessionDocument = HydratedDocument<IChatSession>;
