import * as plugins from '../plugins.ts';
import * as data from '../data/index.ts';

export interface IWorkspaceShellCommand {
  command: string;
  args?: string[];
  label?: string;
  prompt?: string;
}

export interface IReq_WorkspaceReadFile extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceReadFile
> {
  method: 'workspaceReadFile';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    path: string;
  };
  response: {
    content: string;
  };
}

export interface IReq_WorkspaceWriteFile extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceWriteFile
> {
  method: 'workspaceWriteFile';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    path: string;
    content: string;
  };
  response: {};
}

export interface IReq_WorkspaceReadDir extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceReadDir
> {
  method: 'workspaceReadDir';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    path: string;
  };
  response: {
    entries: Array<{ type: 'file' | 'directory'; name: string; path: string }>;
  };
}

export interface IReq_WorkspaceMkdir extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceMkdir
> {
  method: 'workspaceMkdir';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    path: string;
  };
  response: {};
}

export interface IReq_WorkspaceRm extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceRm
> {
  method: 'workspaceRm';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    path: string;
    recursive?: boolean;
  };
  response: {};
}

export interface IReq_WorkspaceExists extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceExists
> {
  method: 'workspaceExists';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    path: string;
  };
  response: {
    exists: boolean;
  };
}

export interface IReq_WorkspaceExec extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceExec
> {
  method: 'workspaceExec';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    command: string;
    args?: string[];
  };
  response: {
    stdout: string;
    stderr: string;
    exitCode: number;
  };
}

export interface IReq_WorkspaceGetShellCommand extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceGetShellCommand
> {
  method: 'workspaceGetShellCommand';
  request: {
    identity: data.IIdentity;
    serviceName: string;
  };
  response: {
    shellCommand: IWorkspaceShellCommand;
  };
}

export interface IReq_WorkspaceStartProcess extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceStartProcess
> {
  method: 'workspaceStartProcess';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    processId: string;
    command: string;
    args?: string[];
  };
  response: {
    processId: string;
  };
}

export interface IReq_WorkspaceProcessInput extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceProcessInput
> {
  method: 'workspaceProcessInput';
  request: {
    identity: data.IIdentity;
    processId: string;
    input: string;
  };
  response: {};
}

export interface IReq_WorkspaceKillProcess extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceKillProcess
> {
  method: 'workspaceKillProcess';
  request: {
    identity: data.IIdentity;
    processId: string;
  };
  response: {};
}

export interface IReq_PushWorkspaceProcessOutput extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_PushWorkspaceProcessOutput
> {
  method: 'pushWorkspaceProcessOutput';
  request: {
    processId: string;
    output: string;
  };
  response: {};
}

export interface IReq_PushWorkspaceProcessExit extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_PushWorkspaceProcessExit
> {
  method: 'pushWorkspaceProcessExit';
  request: {
    processId: string;
    exitCode: number;
  };
  response: {};
}
