/** Workspace instance API client. */

import { apiClient } from "./client";
import type { ToolInstance } from "./sessions";

export async function listWorkspaceInstances(
	workspaceId: string,
): Promise<ToolInstance[]> {
	const response = await apiClient.get<ToolInstance[]>(
		`/workspaces/${workspaceId}/instances/`,
	);
	return response.data;
}

export async function createWorkspaceInstance(
	workspaceId: string,
	toolTypeId: string,
	displayName?: string,
	configProfileId?: string,
): Promise<ToolInstance> {
	const response = await apiClient.post<ToolInstance>(
		`/workspaces/${workspaceId}/instances/`,
		{
			tool_type_id: toolTypeId,
			display_name: displayName,
			config_profile_id: configProfileId,
		},
	);
	return response.data;
}
