Repository: Significant-Gravitas/Auto-GPT
File: autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts (TypeScript)

Code before:

  addMarketplaceAgentToLibrary(
    storeListingVersionID: string,
  ): Promise<LibraryAgent> {
    return this._request("POST", "/library/agents", {
      store_listing_version_id: storeListingVersionID,
    });
  }

  async updateLibraryAgent(
    libraryAgentId: LibraryAgentID,
    params: {
      auto_update_version?: boolean;
      is_favorite?: boolean;
      is_archived?: boolean;
      is_deleted?: boolean;
    },
  ): Promise<void> {
    await this._request("PUT", `/library/agents/${libraryAgentId}`, params);
  }

  /**
   * Clone Library Agent and its underyling graph&nodes.
   * User must own
   */
  deepCloneLibraryAgent(libraryAgentId: LibraryAgentID): Promise<LibraryAgent> {
    return this._request("POST", `/library/agents/${libraryAgentId}/clone`);
  }

  listLibraryAgentPresets(params?: {
    page?: number;
    page_size?: number;
  }): Promise<LibraryAgentPresetResponse> {
    return this._get("/library/presets", params);
  }

  getLibraryAgentPreset(presetId: string): Promise<LibraryAgentPreset> {
    return this._get(`/library/presets/${presetId}`);
  }

  createLibraryAgentPreset(
    preset: CreateLibraryAgentPresetRequest,
  ): Promise<LibraryAgentPreset> {
    return this._request("POST", "/library/presets", preset);
  }

  updateLibraryAgentPreset(
    presetId: string,
    preset: CreateLibraryAgentPresetRequest,
  ): Promise<LibraryAgentPreset> {
    return this._request("PUT", `/library/presets/${presetId}`, preset);

Review comment (suggestion):
nit: `deepClone` is a technical detail that doesn't matter to the client, right? Could be `clone` or `fork` instead.

Code after:

  addMarketplaceAgentToLibrary(
    storeListingVersionID: string,
  ): Promise<LibraryAgent> {
    return this._request("POST", "/library/agents", {
      store_listing_version_id: storeListingVersionID,
    });
  }

  async updateLibraryAgent(
    libraryAgentId: LibraryAgentID,
    params: {
      auto_update_version?: boolean;
      is_favorite?: boolean;
      is_archived?: boolean;
      is_deleted?: boolean;
    },
  ): Promise<void> {
    await this._request("PUT", `/library/agents/${libraryAgentId}`, params);
  }

  forkLibraryAgent(libraryAgentId: LibraryAgentID): Promise<LibraryAgent> {
    return this._request("POST", `/library/agents/${libraryAgentId}/fork`);
  }

  listLibraryAgentPresets(params?: {
    page?: number;
    page_size?: number;
  }): Promise<LibraryAgentPresetResponse> {
    return this._get("/library/presets", params);
  }

  getLibraryAgentPreset(presetId: string): Promise<LibraryAgentPreset> {
    return this._get(`/library/presets/${presetId}`);
  }

  createLibraryAgentPreset(
    preset: CreateLibraryAgentPresetRequest,
  ): Promise<LibraryAgentPreset> {
    return this._request("POST", "/library/presets", preset);
  }

  updateLibraryAgentPreset(
    presetId: string,
    preset: CreateLibraryAgentPresetRequest,
  ): Promise<LibraryAgentPreset> {
    return this._request("PUT", `/library/presets/${presetId}`, preset);
  }

  async deleteLibraryAgentPreset(presetId: string): Promise<void> {
    await this._request("DELETE", `/library/presets/${presetId}`);