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

import { IChatSession } from "../interfaces/chat-session.ts";
import { IDroneRegistration } from "../interfaces/drone-registration.ts";
import { IProject } from "../interfaces/project.ts";
import { GadgetId } from "../lib/gadget-id.ts";

/*
 * requestSessionLock
 */

export type RequestSessionLockCallback = (
  success: boolean,
  chatSessionId: string,
) => void;

export type RequestSessionLockMessage = (
  registration: IDroneRegistration,
  project: IProject,
  chatSession: IChatSession,
  cb: RequestSessionLockCallback,
) => void;

/*
 * requestWorkspaceMode
 */

export enum WorkspaceMode {
  Idle = "idle",
  Syncing = "syncing",
  User = "user",
  Agent = "agent",
}

export type RequestWorkspaceModeCallback = (
  success: boolean,
  mode: WorkspaceMode,
  reason?: string,
) => void;

export type RequestWorkspaceModeMessage = (
  registration: IDroneRegistration,
  project: IProject,
  chatSession: IChatSession,
  mode: WorkspaceMode,
  cb: RequestWorkspaceModeCallback,
) => void;

/*
 * submitPrompt
 */

export interface SubmitPromptCallbackData {
  turnId?: GadgetId;
  message?: string;
}

export type SubmitPromptCallback = (
  success: boolean,
  data: SubmitPromptCallbackData,
) => void;

export type SubmitPromptMessage = (
  prompt: string,
  cb: SubmitPromptCallback,
) => void;

/*
 * releaseSessionLock
 */

export type ReleaseSessionLockCallback = (success: boolean) => void;

export type ReleaseSessionLockMessage = (
  registration: IDroneRegistration,
  project: IProject,
  chatSession: IChatSession,
  cb: ReleaseSessionLockCallback,
) => void;

/*
 * sessionHeartbeat
 */

export type SessionHeartbeatCallback = (ack: boolean) => void;

export type SessionHeartbeatMessage = (cb: SessionHeartbeatCallback) => void;
